Skip to content
4074xx · Client errorThe client seems to have erred. RFC 9110 §15.5

HTTP 407 Proxy Authentication Required: fixes

Meaning

HTTP 407 Proxy Authentication Required means the proxy wants credentials. Read Proxy-Authenticate and send Proxy-Authorization to the proxy.

Covered in a guide401 vs 403 vs 407 at a glanceA section of HTTP 401 vs 403 vs 407: what each code means

HTTP 407 means the proxy wants credentials before it will forward the request: “Proxy Authentication Required”. RFC 9110 section 15.5.8 requires a Proxy-Authenticate challenge, and section 11.7.1 defines the credentials a client sends in Proxy-Authorization. The origin’s WWW-Authenticate header is a different challenge.

For an HTTP URL, the proxy can return 407 directly. For HTTPS, the response normally arrives to the CONNECT request, before the TLS handshake. That is why curl reports “CONNECT tunnel failed, response 407” and a target HTTP code of 000. Credentials in the target URL or an origin -u option do not satisfy the proxy challenge.

Reproduce the challenge and the fix

The local test rig used a Python 3.15.0 proxy that accepts labuser:labpass and a plain HTTP origin. curl 8.7.1 produced:

$ curl -si -x http://127.0.0.1:47407 http://127.0.0.1:47400/
HTTP/1.1 407 Proxy Authentication Required
Server: BaseHTTP Python/3.15.0
Proxy-Authenticate: Basic realm="pw-lab"
Content-Length: 27

proxy credentials required

$ curl -s -o /dev/null -w "%{http_code}\n" -x http://labuser:labpass@127.0.0.1:47407 http://127.0.0.1:47400/
200

$ curl -s -o /dev/null -w "%{http_code}\n" -x http://labuser:wrong@127.0.0.1:47407 http://127.0.0.1:47400/
407

For an HTTPS target, the same no-credential proxy answered 407 during CONNECT:

$ curl -sS -x http://127.0.0.1:47407 https://127.0.0.1:47400/
curl: (56) CONNECT tunnel failed, response 407
http_code=000 http_connect=407

In the Squid 6.13 capture, -U labuser:labpass and a percent-encoded password worked. A raw password containing @ and : was parsed as URL syntax and curl exited 5 before contacting the proxy. Keep credentials in a protected configuration or pass them through the client’s proxy-auth option. Never paste them into logs.

What the challenge tells you

The scheme token in Proxy-Authenticate names the challenge. Basic sends a base64 encoding of user and password, not encryption, so use it only over a protected connection to a trusted proxy. Digest and Negotiate require a multi-step exchange. NTLM may send several 407 responses while the challenge completes. A client that supports only Basic cannot satisfy an NTLM-only proxy.

Inspect the request direction. For an HTTP proxy, the first line has an absolute URL. For CONNECT, it has CONNECT host:port. The proxy credentials belong in Proxy-Authorization, and a well-behaved proxy must not forward that header to the origin. The local capture confirmed that the origin saw no proxy credentials after a successful tunnel.

Do not “solve” 407 by sending credentials as an origin header or by disabling TLS verification. Fix the proxy URL, challenge scheme and credential encoding, then verify the certificate of the target separately.

Causes and fixes

Cause How it shows What to change
No proxy credentials 407 includes Proxy-Authenticate Supply credentials with the client’s proxy option, such as curl -U
Wrong username or password Same 407 after a credentialed request Check the account and avoid retrying a locked account
Credentials sent to the origin -u changes the target request but CONNECT still gets 407 Use proxy credentials, not origin credentials
Unsupported challenge scheme Proxy offers NTLM or Negotiate and the client sends Basic Enable the supported scheme or use a compatible client
Reserved characters in URL credentials curl exits 5 or a Python client raises an invalid URL error Percent-encode the user-info or use a separate credential option
Proxy account quota or policy Correct credentials work for one target but CONNECT receives a policy 407 Read the proxy operator’s account message and check route permissions

Keep 407 separate from a target 401. The 403 vs 407 vs 429 guide compares the challenge headers, and proxy authentication covers the credential exchange. A new exit address does not fix an account challenge unless the proxy’s policy is address based.

When a credentialed request still gets 407, capture the challenge without recording the secret. Check the scheme and realm, verify that the client sends Proxy-Authorization to the proxy, and test one controlled URL before returning to the scraper. A successful HTTP request does not prove an HTTPS tunnel will work if CONNECT uses a different policy.

Frequently asked questions

What header fixes 407?
The client sends Proxy-Authorization after reading Proxy-Authenticate. Do not send Authorization for this purpose.
Why is the target status 000?
The proxy rejected CONNECT before TLS, so the target did not send an HTTP response.

Sources

  1. RFC 9110 section 15.5.8: 407 Proxy Authentication Required
  2. RFC 9110 section 11.7.1: Proxy-Authenticate and Proxy-Authorization

Also covered in

All terms, A to Z