Errors and troubleshooting
How do I fix HTTP 407 Proxy Authentication Required?
Send valid credentials to the proxy in a form your client understands, or add your machine's IP to the proxy's allowlist; the target site is not involved at all.
Where the 407 comes from
A 407 is the proxy refusing you before your request ever reaches the website. It is the proxy's version of a 401: "who are you?" It means one of four things: no credentials were sent, the credentials are wrong, they were mangled on the way (usually by special characters), or the proxy expects an IP allowlist and your address is not on it. Fixing it is almost always a configuration change on your side or in the provider dashboard.
Check the credentials with curl
Isolate the proxy from your code. If this command returns 407, the problem is the credentials or the account, not your scraper:
curl -sS -o /dev/null -w "%{http_code}\n" \
--proxy "http://203.0.113.55:9000" --proxy-user "probe_user:Qm9zK1" \
https://example.com/
Passing credentials with --proxy-user avoids URL encoding problems while you test. If curl succeeds and your program fails, compare how your program passes them.
Common causes and fixes
- Special characters in the password. In URL form,
@,:,/,#and%break parsing. Percent-encode the username and password, or pick a password without them. - Credentials set only for one scheme. In Python requests, setting
proxies={"http": ...}and forgetting"https"sends HTTPS traffic without the proxy or without credentials, depending on the setup. - Browser automation. Chromium ignores credentials embedded in
--proxy-server. Use the tool's own option: Playwright takesproxy: {server, username, password}, Puppeteer usespage.authenticate(). - IP allowlist mode. The provider accepts only listed IPs. Add your server's public IP in the dashboard, or switch the proxy user to password mode.
- Expired plan or wrong zone. Some providers answer 407 when the account has no traffic left or the user lacks access to that proxy type.
- Corporate proxy in the chain. A company proxy that needs NTLM or Kerberos authentication can answer 407 before your scraping proxy is reached.
Fixing it in code
import os
import urllib.parse
import requests
user = urllib.parse.quote(os.environ["PROXY_USER"], safe="")
secret = urllib.parse.quote(os.environ["PROXY_PASS"], safe="")
gateway = os.environ["PROXY_GATEWAY"] # host:port
via = f"http://{user}:{secret}@{gateway}"
r = requests.get("https://example.com/", proxies={"http": via, "https": via}, timeout=20)
print(r.status_code)
Keeping credentials in environment variables also stops them from leaking into logs and repositories. The page on how proxy authentication works explains the header behind all this.
407 inside a CAPTCHA task
When you pass a proxy in a task, such as AntiCloudflareTask or DatadomeSliderTask, the solver connects to your proxy from its own servers. If the proxy only allows your server's IP, it answers the solver with 407 and the task fails. That failure is not charged. Use username and password authentication for proxies you hand to tasks, encode special characters as shown above, and test the exact string first. The format is described on proxy format for tasks.
Not to be confused with
A 401 comes from the website and is about your login there. A 403 from the site is a refusal, often bot protection; see what 403 means. Only 407 is about the proxy's own authentication, which is why changing headers or user agents never fixes it.
A quick checklist
Test with curl and --proxy-user. Encode special characters. Set the proxy for both schemes. Use the automation tool's own credential option. Check the provider dashboard for allowlist mode and remaining traffic. Nine times out of ten, one of these five steps finds the fault in a few minutes.
Once it works, save the working command or config snippet in your project notes. Proxy settings are touched rarely, and the next person to change them will be glad of a known good example.
Common questions
Is a 407 error from the website?
No. It comes from the proxy server, before the request is forwarded to the site.
Why does Playwright give 407 with credentials in the URL?
Chromium ignores credentials in the proxy server address; pass username and password in Playwright's proxy option.
Can an IP allowlist cause 407?
Yes. Requests from an address that is not on the list are refused with 407 or a closed connection.
How do I encode a password with @ in it?
Replace @ with %40, or URL-encode the whole password with your language's quote function.
Is a solving task charged when my proxy returns 407?
No. The task fails because the proxy refused the solver, and failed tasks are free.
Keep reading
- How does proxy authentication work?Proxies check either a username and password sent with each request, or an allowlist of the client IP addresses.
- How do I test a proxy before using it?Check that it connects, shows the exit IP and country you expect, answers quickly and reaches your target without a block.
- Proxy serverA forward proxy relays requests under its own address; see what it changes, what it keeps and how credentials are written.
- What proxy format does a solving task accept?Tasks take one proxy string in URL form, http://user:pass@host:port, in the proxy field of the task object.