HTTP: 407 Proxy Authentication Required
Last verified
ProxyError('Unable to connect to proxy', OSError('Tunnel connection failed: 407 Proxy Authentication Required'))What it means
407 comes from a proxy between you and the website, not from the website. It works like 401, but for the proxy: the proxy requires credentials and sends a Proxy-Authenticate header describing the scheme. Until the proxy accepts your credentials, your request never reaches the target site.
It most often appears on corporate networks that route traffic through an authenticating proxy, in CI or container environments that inherit HTTP_PROXY/HTTPS_PROXY variables, and with commercial proxy services when the username or password in the proxy URL is wrong. In Python requests, an HTTPS request through a proxy surfaces it as a ProxyError wrapping "Tunnel connection failed: 407".
What is not wrong: the target website has not blocked you. Fixing your code's handling of the target will not help.
What it looks like
proxies = {"https": "http://user:p%[email protected]:8080"}
requests.get("https://example.com", proxies=proxies, timeout=30)Why it happens
- Proxy credentials are missing, wrong or expired.
- Special characters in the username or password are not URL-encoded in the proxy URL.
- The environment sets HTTPS_PROXY globally, so the script uses a proxy you did not intend.
- The proxy uses NTLM or Kerberos, which the HTTP client does not support natively.
How to fix it
- Print the effective proxy settings (environment variables and code) to confirm which proxy is used.
- Put credentials in the proxy URL as http://user:password@host:port, URL-encoding special characters.
- Verify the credentials with curl -x http://user:pass@host:port https://example.com -I.
- If you did not intend to use a proxy, unset the variables or add the host to NO_PROXY.
- On corporate networks, ask IT for the approved proxy configuration and authentication method.
How to stop it recurring
Keep proxy configuration explicit in one place, store credentials as secrets, and test connectivity at startup. Document NO_PROXY for internal hosts so local services do not route through the proxy.
Official documentation: developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/407. See all HTTP error messages.
Related errors
- 401 Unauthorizedrequests.exceptions.HTTPError: 401 Client Error: Unauthorized for url:…
- Max retries exceeded with urlrequests.exceptions.ConnectionError: HTTPSConnectionPool(host='example.com',…
- ConnectionResetError: Connection reset by peerrequests.exceptions.ConnectionError: ('Connection aborted.',…
Definitions
- CAPTCHACAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) is a challenge-response m
- Cloudflare Bot ManagementCloudflare Bot Management is the set of Cloudflare features (Bot Fight Mode, Super Bot Fight Mode and the Ente
- DataDomeDataDome is a commercial bot-protection service that scores every request to a website, app or API in real tim
- HUMAN Security (PerimeterX)PerimeterX, now HUMAN Security's Bot Defender after a 2022 merger, is a bot-protection service that scores eve
- User AgentA user agent is a string that browsers send with every HTTP request identifying the browser type, version, and
- AI Web ScraperAn AI web scraper is an AI-powered data extraction tool that understands page structure, identifies relevant d
- Data ScrapingData scraping is the broad practice of programmatically extracting data from any digital source — websites, ap
- Web CrawlerA web crawler (also called a spider or bot) is a program that systematically browses the internet by following
Quick answers
What does "407 Proxy Authentication Required" mean in HTTP?
407 comes from a proxy between you and the website, not from the website. It works like 401, but for the proxy: the proxy requires credentials and sends a Proxy-Authenticate header describing the scheme. Until the proxy accepts your credentials, your request never reaches the target site.
How do I fix "407 Proxy Authentication Required"?
1. Print the effective proxy settings (environment variables and code) to confirm which proxy is used. 2. Put credentials in the proxy URL as http://user:password@host:port, URL-encoding special characters. 3. Verify the credentials with curl -x http://user:pass@host:port https://example.com -I. 4. If you did not intend to use a proxy, unset the variables or add the host to NO_PROXY. 5. On corporate networks, ask IT for the approved proxy configuration and authentication method.
Retries and timeouts without writing the loop
Autonoly's HTTP Request node and browser steps have per-node retries, timeouts and continue-on-fail, so a transient 429 or 503 can back off instead of failing the run. It has no proxies or IP rotation: if a site blocks automated traffic, that block applies to Autonoly too.
Also see Error handling in workflows.