TrueSocks

Guides · 7 min

Proxy Error 407 and Other Proxy Errors: Causes and Fixes

  • TrueSocks editorial team
  • 7 min read

HTTP 407 Proxy Authentication Required means the proxy itself refused your request because it did not get valid credentials: the login or password is wrong, missing, badly encoded, or your IP is not on the proxy's allowlist. Most other proxy errors fall into a few groups too: the proxy cannot be reached at all, the protocol does not match the port, or the proxy reached the website but the website refused or did not answer. This guide explains how to tell these groups apart and fix each error, with ready commands for curl, Python and browsers.

Key takeaways

5 points
  • 407 comes from the proxy, not the website: check login, password, special characters and the IP allowlist.
  • 403 and 429 come from the target site: the proxy works, but the IP, request rate or client fingerprint is not welcome.
  • 502, 503 and 504 mean the proxy could not get a good answer from the next hop; retry, then check the target and the protocol.
  • Connection refused, reset or an instant failure usually means the wrong port or HTTP spoken to a SOCKS5 port.
  • Isolate the problem with one curl command before touching browser or app settings.

First question: who returned the error?

#

Every request through a proxy has two legs: from you to the proxy, and from the proxy to the website. An error can come from either side, and the fix depends on which. The quickest way to tell them apart:

ErrorWho sends itWhat it usually means
407 Proxy Authentication RequiredProxyMissing or wrong credentials, or your IP is not allowlisted
Connection refused, reset, timed outNetwork or proxyWrong host or port, protocol mismatch, firewall
502 Bad GatewayProxyThe proxy got an invalid answer or no connection from the target
503 Service UnavailableProxy or targetOverloaded or unavailable upstream, sometimes a rate limit
504 Gateway TimeoutProxyThe target did not answer the proxy in time
403 ForbiddenTarget siteThe site refuses this IP or this client
429 Too Many RequestsTarget siteRate limit on the IP or session
Status codes are defined in RFC 9110 (407, 502, 503, 504, 403) and RFC 6585 (429).

A simple test: request a plain IP echo service through the proxy. If that works and only your target fails, the proxy is fine and the problem is the target's reaction to your traffic.

Baseline test with verbose output
curl -v -x http://login:[email protected]:8000 https://api.ipify.org

407 Proxy Authentication Required

#

A 407 response is the proxy's way of saying "who are you?". It comes with a Proxy-Authenticate header, typically Basic realm=..., and the client is expected to retry with a Proxy-Authorization header. In curl it usually shows up as Received HTTP code 407 from proxy after CONNECT; in Python requests as ProxyError ... Tunnel connection failed: 407 Proxy Authentication Required.

Causes and fixes

  1. Copy the credentials again

    Logins and passwords are case sensitive. Copy them from the order page, check for trailing spaces and line breaks, and make sure login and password did not swap places when the string was split.

  2. Encode special characters

    If the password contains @, :, /, # or %, it breaks the login:password@host:port URL format. URL-encode it (@ becomes %40, : becomes %3A) or pass credentials separately, for example with curl's -U login:password.

  3. Check the authorization method

    If the proxy uses an IP allowlist instead of a login, it answers 407 to any address that is not on the list. Your IP changes when you switch networks or turn on a VPN. Add the new address or switch to login and password.

  4. Check the expiry date

    An expired rental usually fails authentication. Confirm the proxy is still active.

  5. Check the client supports proxy auth

    Chrome's --proxy-server flag ignores credentials in the URL, and Chromium does not support username and password for SOCKS5 at all. Use the app's own auth field, an extension, an IP allowlist or a local forwarder.

Encode a password in Python
from urllib.parse import quote

login = 'user123'
password = quote('p@ss:word#1', safe='')   # 'p%40ss%3Aword%231'
proxy = f'http://{login}:{password}@203.0.113.10:8000'

Connection refused, reset or timed out

#

These errors mean you never had a working conversation with the proxy. In Chrome and Edge they appear as ERR_PROXY_CONNECTION_FAILED or ERR_SOCKS_CONNECTION_FAILED; in curl as error (7) Failed to connect or (28) Connection timed out.

  • Refused instantly: the host is reachable but nothing listens on that port. Check the port number in your order.
  • Reset or empty reply: something answered, but in a different protocol. Speaking HTTP to a SOCKS5 port or SOCKS5 to an HTTP port looks exactly like this.
  • Timed out: wrong host, the proxy is down, or a firewall, antivirus or corporate network on your side blocks outgoing connections to that port. Try from another network such as mobile data to rule out your side.
  • Could not resolve proxy (curl error 5): a typo in the hostname or an invisible character copied with it.
Try both protocols on the same port
# as HTTP
curl -v -x http://login:[email protected]:8000 https://api.ipify.org

# as SOCKS5 with DNS on the proxy side
curl -v -x socks5h://login:[email protected]:8000 https://api.ipify.org

If one works and the other does not, you have found a protocol mismatch. Many providers issue separate ports for HTTP and SOCKS5. The differences between the two are explained in what is a SOCKS5 proxy.

ERR_TUNNEL_CONNECTION_FAILED and CONNECT failures

#

To open an HTTPS site, the browser asks an HTTP proxy to create a tunnel with CONNECT host:443. ERR_TUNNEL_CONNECTION_FAILED means the proxy did not return 200 Connection established. Typical reasons:

  • Authentication failed during CONNECT (a 407 hidden behind the generic message).
  • The proxy could not reach the target host or port, or does not allow CONNECT to that port.
  • An IPv6-only proxy was asked to reach a site that has no IPv6 address; see IPv4 vs IPv6 proxies.
  • Antivirus or a corporate filter on your machine intercepts HTTPS and breaks the tunnel.

Test with curl -v and look at the line after CONNECT: it shows the exact status the proxy returned, which the browser hides.

502 Bad Gateway, 503 Service Unavailable, 504 Gateway Timeout

#

These are gateway errors: the proxy accepted your request but could not get a valid response from the next hop. With rotating residential and mobile pools, the next hop is often a home or carrier connection that just went offline.

CodeLikely causeFix
502Target refused the connection, or the exit node droppedRetry with a new session; check the target opens directly
503Proxy or exit pool overloaded, or a rate limitBack off and retry; reduce concurrency
504Target or exit too slow to answerRaise timeouts, use a closer country, retry
Occasional gateway errors are normal on residential and mobile pools; build retries into your code.
Retry with backoff in Python
import time, random, requests

PROXY = 'http://login:[email protected]:8000'

def get(url, tries=4):
    for i in range(tries):
        try:
            r = requests.get(url, proxies={'http': PROXY, 'https': PROXY}, timeout=20)
            if r.status_code in (502, 503, 504, 429):
                raise requests.HTTPError(r.status_code)
            return r
        except (requests.ConnectionError, requests.Timeout, requests.HTTPError):
            time.sleep(2 ** i + random.random())
    raise RuntimeError('proxy request failed: ' + url)

403 Forbidden and 429 Too Many Requests

#

When you get 403 or 429 from the target, the proxy has done its job: your request arrived. The site decided it does not like the source. Three things decide that: the IP and its network type, the request rate, and how much your client looks like a real browser.

Fixes that usually help

  • Lowering requests per IP and adding random delays.
  • Honoring Retry-After on 429 responses.
  • Sending realistic headers and keeping cookies per session.
  • Switching to ISP, residential or mobile IPs for strict sites.

Fixes that rarely help

  • Retrying the same request instantly in a loop.
  • Buying more IPs from the same blocked subnet.
  • Changing proxy protocol from HTTP to SOCKS5: the site sees the same IP.
  • Rotating IPs on a logged-in session, which looks like account theft.

Pool size and rotation strategy are covered in how many proxies do I need and rotating vs static proxies.

Errors in Python, Node.js and browsers

#
MessageMeaningFix
InvalidSchema: Missing dependencies for SOCKS supportPython requests without SOCKS supportpip install requests[socks]
ProxyError: Cannot connect to proxyProxy unreachable from your machineCheck host, port and firewall
SSLError only through the proxyWrong scheme or an intercepting filterUse http:// for the proxy URL even for HTTPS targets
ERR_NO_SUPPORTED_PROXIESChromium got a proxy setup it cannot use, for example SOCKS5 with credentialsUse the HTTP port or a local forwarder
Browser keeps asking for loginWrong credentials or a cached bad loginRestart the browser, re-enter credentials
Works in curl, fails in the appApp settings: protocol, DNS mode, system proxyCompare the exact URL the app uses
The proxy URL scheme describes how you talk to the proxy, not the target: an HTTP proxy is http:// even for HTTPS sites.

Browser automation has its own quirks with authentication. Ready code for each framework is in proxies for Selenium, Playwright and Puppeteer, and antidetect tools are covered in the antidetect browser proxy setup.

A 5-minute troubleshooting checklist

#
  1. Validate the proxy line in the free proxy checker: it parses ip:port:login:password, login:password@ip:port and URL formats and flags broken lines.
  2. Run one curl -v request to an IP echo service. Note the exact error.
  3. If you see 407: credentials, special characters, allowlist, expiry.
  4. If the connection fails: port, protocol, firewall. Try both http:// and socks5h://.
  5. If the proxy works but the target fails: rate, headers, IP type. Test the target in a browser through the same proxy.
  6. Only then change app settings, and compare them with the working curl command.

Frequently asked questions

What does 407 Proxy Authentication Required mean?

The proxy server rejected the request because it did not receive valid credentials. Check the login and password, encode special characters, and make sure your current IP is allowlisted if the proxy uses IP authorization.

What is the difference between 407 and 401?

401 Unauthorized comes from the website and asks you to log in to the site. 407 comes from the proxy and asks for proxy credentials. They use different headers: WWW-Authenticate for 401 and Proxy-Authenticate for 407.

Why do I get 502 Bad Gateway through a proxy?

The proxy could not get a valid response from the target or from its exit node. On rotating pools an exit node may have gone offline. Retry with a new session and check that the site opens without the proxy.

Why does my proxy work in curl but not in my browser?

The browser is using a different protocol, port or authentication method, or a system proxy and extensions interfere. Chromium also does not support SOCKS5 with a password. Match the browser settings to the working curl command.

TrueSocks editorial team

Proxy guides and setup notes

Written by the people behind the TrueSocks catalog and support desk. Found a mistake or an outdated step? Let us know in Telegram and we will fix it.

Now boarding

Proxies for this task

Starting price per unit for the base term. Countries and volume discounts are listed on each product page.

  • #proxy errors
  • #407
  • #troubleshooting
  • #curl
  • #python

Proxies are provided for lawful use only. Spam, fraud and hacking are prohibited; follow the rules of the platforms you work with. Terms of service

All articles