Skip to content

407 Proxy Authentication Required — Meaning, Common Causes & How to Fix

407 4xx Client Error RFC 9110 §15.5.8

407 Proxy Authentication Required means: Like 401, but the authentication challenge comes from an intermediary proxy rather than the origin server. The client must authenticate with the proxy (Proxy-Authenticate header) before the request is forwarded. Client-error 4xx codes mean the request itself is the problem: malformed syntax, missing credentials, forbidden access, a nonexistent resource or a violated precondition. The server is telling the client what to change; retrying the identical request without a fix will reproduce the same error. In practice you will meet 407 when a corporate forward proxy requires credentials; an egress gateway in a cloud vpc enforces proxy authentication; a scraping or ci environment sits behind an authenticating proxy. On the client side, supply proxy credentials via the client's proxy configuration (not the Authorization header); libraries distinguish proxy auth from origin auth. On the server side, proxies should send Proxy-Authenticate with the scheme; origins never emit 407 — if you see it, the problem is between you and the origin.

Advertisement
Ad slot · ref-top

When 407 happens

  • A corporate forward proxy requires credentials
  • An egress gateway in a cloud VPC enforces proxy authentication
  • A scraping or CI environment sits behind an authenticating proxy

How to fix it

On the client

Supply proxy credentials via the client's proxy configuration (not the Authorization header); libraries distinguish proxy auth from origin auth.

On the server

Proxies should send Proxy-Authenticate with the scheme; origins never emit 407 — if you see it, the problem is between you and the origin.

Should you retry?

Not retryable as-is: change the request (credentials, payload, URL) first.

Debugging steps

When 407 appears unexpectedly, start by capturing the full exchange: 'curl -i' or the browser DevTools Network tab shows the exact status line and response headers, which often carry the real explanation. Read the error body first — well-designed APIs name the offending field or missing credential. Then diff your actual request, headers included, against the documented contract. For this code specifically, check whether the most common trigger applies to your situation: a corporate forward proxy requires credentials. Compare your exchange against the raw HTTP example above. If you operate the server, correlate the timestamp with application and proxy logs using the request id; if you are the client, verify the request shape against the API documentation before changing anything or retrying.

Notes & gotchas

Proxy credentials travel in Proxy-Authorization, not Authorization; sending origin credentials to a proxy (or vice versa) is the most common 407 debugging mistake in corporate environments.

Examples

Raw HTTP
HTTP/1.1 407 Proxy Authentication Required
Proxy-Authenticate: Basic realm="corporate-proxy"
Content-Type: application/json
Content-Length: 109

{
  "error": "proxy_authentication_required",
  "message": "A corporate forward proxy requires credentials"
}
curl
curl -i --proxy http://user:pass@proxy.corp.example:8080 https://api.example.com/v1/resource
JavaScript (fetch)
const res = await fetch("https://api.example.com/v1/resource");
if (res.status === 407) {
  const problem = await res.json(); // read field-level details
  // fix the request (credentials, payload, URL) — identical retries keep failing
  throw new RequestError(problem);
}
Python (requests)
import requests

res = requests.get("https://api.example.com/v1/resource", timeout=10)
if res.status_code == 407:
    problem = res.json()  # field-level error details
    # correct the request before retrying — identical retries keep failing
    raise RequestProblem(problem)

Frequently asked questions

Where do I put credentials for 407?

In the proxy URL or proxy-auth settings of your HTTP client (e.g. http://user:pass@proxy:port), which produces Proxy-Authorization, not Authorization.

Why does curl work but my app gets 407?

curl may pick up system proxy settings or .curlrc; your app's library needs explicit proxy configuration including credentials.

Are 4xx errors always the client's fault?

By contract yes — the server asserts the request must change. In practice servers sometimes misuse 4xx for their own problems (e.g. 400 for internal validation bugs), so read the error body before blaming your client code.

Should I retry 4xx responses automatically?

Generally no: the server says the request must change. Exceptions are 408 (fresh connection), 425 (after handshake) and 429 (after Retry-After). Blind retries of 400/401/403/404 just burn quota.

Advertisement
Ad slot · ref-in-article

Try the JSON Validator

Check JSON syntax and locate errors by line and column.

Open tool →