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
- Wrong or missing credentials. A typo, an expired password, or a proxy plan that has been suspended. This is the most common cause by far.
- Special characters in the password. Characters such as
@,:,/,#,?and%break a proxy URL likehttp://user:p@ss@host:8080. They must be percent-encoded:@becomes%40,:becomes%3A,/becomes%2F. - Authentication scheme mismatch. Your client sends Basic, but the proxy only offers NTLM, Negotiate (Kerberos) or Digest. Corporate proxies often use NTLM or Kerberos, which many scripting libraries do not speak.
- IP whitelisting instead of user and password. Some providers authenticate by source IP. If your IP changed, or you are connecting from a different machine, the proxy answers 407 even with correct credentials. The reverse also happens: you send credentials to a proxy that expects a whitelisted IP.
- Credentials not sent on the tunnel. Some clients send credentials for plain HTTP requests but not for the
CONNECTrequest used for HTTPS. - Wrong proxy for the protocol. Sending requests to a SOCKS5 port as if it were an HTTP proxy, or the reverse, can produce errors that look like authentication failures.
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
- Chrome and Edge use the operating system proxy settings and show a sign-in dialog when they get a 407. If the dialog never appears, or keeps reappearing, the saved credentials are wrong; close all browser windows and try again.
- Firefox has its own proxy settings (Settings, then Network Settings). Enter the credentials when prompted, and tick the option to remember them only on a machine you trust.
- Automation tools. Chrome ignores credentials placed inside
--proxy-server. With Puppeteer, pass the address in the flag and callpage.authenticate({ username, password })separately.
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
- Re-type the username and password; check for trailing spaces from copy and paste.
- Percent-encode special characters in any proxy URL.
- Run curl with
-vand readProxy-Authenticateto see the scheme required. - Check whether the provider uses IP whitelisting and whether your current IP is on the list.
- Confirm you are using the right protocol and port for the credentials you have.
Related reading: how to check if a proxy is working.