Skip to content
$ learn proxy-407

Proxy error 407: authentication required

Why a proxy answers 407 and how to fix it in curl, Python, Node.js and browsers.

HTTP 407 Proxy Authentication Required means the proxy server is working and reachable, but it refused your request because it did not accept your credentials, or did not receive any. It is the proxy's equivalent of 401 Unauthorized. Unlike a timeout or a refused connection, a 407 tells you the network path is fine and the problem is authentication.

What the 407 response means

When a proxy requires authentication, it answers with a 407 status and a Proxy-Authenticate header that names the schemes it accepts. The client is expected to retry with a Proxy-Authorization header. A typical exchange looks like this:

HTTP/1.1 407 Proxy Authentication Required
Proxy-Authenticate: Basic realm="proxy"

GET http://example.com/ HTTP/1.1
Proxy-Authorization: Basic dXNlcjpwYXNz

With HTTPS targets the same thing happens on the CONNECT request, before any TLS starts. Many tools then report a confusing message such as "Received HTTP code 407 from proxy after CONNECT" or "Tunnel connection failed: 407 Proxy Authentication Required".

Common causes

Fixing it with curl

Run curl with -v and read the Proxy-Authenticate header in the response. It tells you which scheme the proxy wants.

curl -v -x http://203.0.113.10:8080 --proxy-user 'user:pa$$word' https://api.ipify.org

# let curl pick the strongest scheme the proxy offers
curl -x http://203.0.113.10:8080 --proxy-user user:pass --proxy-anyauth https://api.ipify.org

# force a scheme
curl -x http://203.0.113.10:8080 --proxy-user user:pass --proxy-basic https://api.ipify.org
curl -x http://203.0.113.10:8080 --proxy-user user:pass --proxy-ntlm https://api.ipify.org

With --proxy-user the password is passed as typed, so no URL-encoding is needed, but your shell may still interpret characters such as $. Use single quotes in a shell. If you put credentials in the proxy URL instead, encode them.

Fixing it in Python requests

The usual mistake is a raw password in the URL. Encode it with urllib.parse.quote and set safe='' so that / is encoded as well:

import requests
from urllib.parse import quote

user = quote("user", safe="")
pw = quote("p@ss:w/rd#1", safe="")
proxy = f"http://{user}:{pw}@203.0.113.10:8080"

r = requests.get("https://api.ipify.org",
                 proxies={"http": proxy, "https": proxy},
                 timeout=15)
print(r.status_code, r.text)

Note that the proxy URL scheme stays http:// even for the https key, because that scheme describes how you talk to the proxy, not the target. For NTLM, requests has no built-in support; a third-party package such as requests-ntlm is the usual route, or run a local forwarding proxy that handles NTLM for you.

Fixing it in Node.js

axios has a proxy option, but its handling of HTTPS targets through a proxy has been unreliable for many people. A dependable approach is a proxy agent, with axios' own proxy handling turned off:

const axios = require('axios');
const { HttpsProxyAgent } = require('https-proxy-agent');

const user = encodeURIComponent('user');
const pass = encodeURIComponent('p@ss:w/rd#1');
const agent = new HttpsProxyAgent(`http://${user}:${pass}@203.0.113.10:8080`);

axios.get('https://api.ipify.org', { httpsAgent: agent, proxy: false })
  .then(r => console.log(r.data))
  .catch(e => console.error(e.response ? e.response.status : e.message));

If you get a 407 here, the credentials or scheme are wrong; the agent has no NTLM support. Our guide on using a proxy with curl, Python and Node.js covers the other clients.

Fixing it in browsers

How to test the proxy before you debug your code

Separate "the proxy rejects me" from "my code is wrong" by testing the proxy on its own. Paste it as ip:port:user:pass into the proxy checker. If the checker also fails, the credentials, the whitelist, or the subscription are the problem, and you should contact the provider. If the checker passes but your code gets a 407, compare what your client sends: usually it is encoding, the scheme, or a missing credential on the CONNECT request.

Quick checklist

  1. Re-type the username and password; check for trailing spaces from copy and paste.
  2. Percent-encode special characters in any proxy URL.
  3. Run curl with -v and read Proxy-Authenticate to see the scheme required.
  4. Check whether the provider uses IP whitelisting and whether your current IP is on the list.
  5. Confirm you are using the right protocol and port for the credentials you have.

Related reading: how to check if a proxy is working.

Published and last updated 2026-12-02