# 407 Proxy Authentication Required lab

This download reproduces `407 Proxy Authentication Required` on your own
machine and then runs the fixes from the guide at
https://ipvolt.com/guides/fix-proxy-error-407.

The "proxy" is one small Node.js server on `127.0.0.1` that demands HTTP Basic
authentication (`labuser` with the password `labpass` or `p@ss/w0rd#1`) and
otherwise forwards to the real destination, `https://example.com/` by default.
No proxy account is needed. The only outbound traffic goes to that destination
and to package installation.

Phase 1 (`symptoms.py` plus the Playwright, Puppeteer and curl cases inside
`lab.mjs`) records what each client reports when credentials are missing, wrong
or placed in the website-authentication option instead of the proxy option.
Phase 2 runs the five samples printed in the article, each with a normal
password, a special-character password and a wrong password:

- `fix_requests.py` (requests)
- `fix_httpx.py` (httpx)
- `fix_aiohttp.py` (aiohttp)
- `fix-playwright.mjs` (Playwright, Chromium)
- `fix-puppeteer.mjs` (Puppeteer)

`results.json` is the recorded run behind the article. It was produced on
19 September 2026 on Linux with Python 3.14.4, requests 2.34.2, httpx 0.28.1,
aiohttp 3.14.3, urllib3 2.8.0, Node.js 24.20.0, Playwright 1.63.0 (Chromium
153.0.8010.12) and curl 8.18.0. Puppeteer resolved to puppeteer-core 25.11.0
through a local shim that pointed it at the same Chromium build and added
`--no-sandbox`, because the recording ran as root; the sample files themselves
were not modified. These are dated observations for those versions, not a
promise about future releases.

## Run the lab

Requirements: Node.js 20 or newer, Python 3.10 or newer, curl on the PATH,
and network access to the destination. Do not run browsers as root.

```sh
python3 -m venv .venv && . .venv/bin/activate && pip install -r requirements.txt
npm install
npx playwright install chromium
npm run lab
```

`lab.mjs` prints one JSON line per case and writes `results.json` when it
finishes. Set `PYTHON` to another interpreter, `TARGET_URL` and
`HTTP_TARGET_URL` to another destination, if needed.

## Run one fix sample against your own proxy

Each sample reads `PROXY_URL` (scheme, host and port, no credentials inside),
`PROXY_USERNAME`, `PROXY_PASSWORD` and an optional `TARGET_URL`:

```sh
export PROXY_URL=http://gate.example.net:8080 PROXY_USERNAME=... PROXY_PASSWORD=...
python fix_requests.py
node fix-playwright.mjs
```

Keep credentials in environment variables or a secret manager; never commit
them or paste a credential-bearing URL into a bug report.
