New videos every week — proxies, VPNs & antidetect browsers, explained.

Subscribe
GuidesNov 24, 202616 min read

Proxy Authentication Explained: Username/Password vs IP Whitelist

How proxy authentication works: username/password vs IP whitelisting, the SOCKS5 Chrome limitation, the shared-IP trap and storing credentials safely.

Table of contents

Every paid proxy has to answer one question before it forwards a single byte: are you allowed to use me? Providers answer it in one of two ways. Either your client proves who it is with a username and password, or the proxy checks the IP address your connection comes from against a list you registered in advance. Both work, both are standard, and both fail in ways that confuse people the first time. This guide explains how proxy authentication actually works on the wire, when to choose username/password and when to choose an IP whitelist, why SOCKS5 with a password often doesn't work in Chrome-based tools, the shared-IP trap that catches whitelisting users, and how to store proxy credentials without leaking them.

What proxy authentication is, and why providers insist on it

A proxy that accepts traffic from anyone is an open proxy, and open proxies get found, abused and blocklisted quickly. Paid providers also bill by bandwidth, by IP or by port, so they need to know which customer each connection belongs to. Authentication solves both problems: it keeps strangers off the network and ties every request to an account, a plan and a usage meter.

There are two families of methods:

  • Credential-based authentication (usually called user:pass). Your client sends a username and password to the proxy. The proxy checks them and either forwards the request or refuses it.
  • IP-based authentication (called IP whitelisting, IP allowlisting or IP authorization). You register one or more public IP addresses in the provider's dashboard. Any connection arriving from those addresses is accepted with no password at all.

Most commercial providers offer both, and many let you use them side by side on the same plan. Which one you should use depends less on security in the abstract and more on where your code runs, what software is making the requests and how often your own IP address changes. If you are new to how proxies sit between you and a website, our explainer on what a proxy server is covers the basics.

How username/password authentication works on the wire

The mechanics differ slightly between HTTP proxies and SOCKS5 proxies, and the difference matters when something breaks.

HTTP and HTTPS proxies: the 407 challenge

With an HTTP proxy, authentication rides inside ordinary HTTP headers. The flow looks like this:

  1. Your client sends a request to the proxy, or a CONNECT request if the target is an https:// URL.
  2. If no credentials are attached, the proxy answers 407 Proxy Authentication Required and includes a Proxy-Authenticate header that names the scheme it expects, most often Basic.
  3. The client repeats the request with a Proxy-Authorization header carrying the credentials.
  4. If they check out, the proxy forwards the request (or opens the tunnel) and the target's response comes back as normal.

Many clients skip the first round trip and send Proxy-Authorization up front when you give them credentials. With the Basic scheme, the header value is simply username:password encoded in Base64. Base64 is an encoding, not encryption: anyone who can read the header can decode the password instantly.

Flowchart: CLIENT sends a request to PROXY, which answers 407 and loops back; the client returns with CREDENTIALS and reaches ACCESS GRANTED
An HTTP proxy challenges with 407, the client retries with a Proxy-Authorization header, and only then is the request forwarded.

That raises an important point about what is actually protected. When you fetch an https:// site through a plain HTTP proxy, the page content is encrypted end to end inside the CONNECT tunnel, but the CONNECT request itself, including the target hostname and your Proxy-Authorization header, travels to the proxy unencrypted. Chromium's own networking documentation notes that communication with an HTTP proxy is insecure and that the target hostname is sent to the proxy in the clear when the tunnel is set up. If the path between you and the proxy is untrusted (public Wi-Fi, a shared network), your proxy password is exposed on it. Some providers offer an HTTPS proxy endpoint, where the connection to the proxy itself is wrapped in TLS; curl supports this with the https:// proxy scheme.

SOCKS5 proxies: a separate sub-negotiation

SOCKS5 works at a lower level and doesn't use HTTP headers. When a client connects, it lists the authentication methods it supports and the server picks one. If the server picks username/password, the client sends a small binary message defined in RFC 1929 containing the username and password, each up to 255 bytes. The server replies with a status byte: zero means success, anything else means failure and the connection is closed. If the client offered no method the server accepts, the server answers with the "no acceptable methods" code and hangs up before any traffic flows.

RFC 1929 is blunt about the security of this exchange: because the request carries the password in cleartext, the method is not recommended where sniffing is possible. In practice that means the same advice as HTTP: treat proxy credentials as exposed on any network you don't trust. For more on how the two protocols differ beyond authentication, see SOCKS5 vs HTTP proxies.

How IP whitelisting works

IP whitelisting moves the check from "what do you know" to "where are you coming from". You add your server's or office's public IPv4 address (and, where supported, IPv6) to an allowlist in the provider dashboard. From then on, the proxy gateway looks at the source address of each incoming TCP connection. If it is on your list, the connection is accepted and billed to your account. If not, it is refused.

The appeal is that nothing secret travels with your requests. There is no password in your code, your environment variables or your browser profile, and no header for anyone to sniff. Tools that can't send proxy credentials at all, including some browsers, scrapers, mobile apps and legacy software, work fine because from their point of view it's an ordinary unauthenticated proxy.

The weakness is the mirror image of that strength: the proxy trusts the address, not the person. Anyone and anything that can send traffic from a whitelisted IP gets access. That is harmless on a dedicated server you control and risky on a network you share.

Whitelist the address the proxy sees

The IP you must register is your public egress address as seen from the internet, not the private address on your network card (for example 192.168.x.x or 10.x.x.x). Check it by requesting an IP-echo endpoint without the proxy from the exact machine that will run your code.

Username/password vs IP whitelist: side-by-side

FactorUsername/passwordIP whitelist
What proves accessCredentials sent with each connectionThe source IP of the connection
Works from anywhereYes: laptops, CI runners, serverless, changing networksOnly from registered public IPs
Secrets to protectYes: the password can leak through code, logs or sniffingNone in the client, but the whitelisted network becomes the "secret"
Who else gets accessAnyone holding the credentialsAnyone sending traffic from that IP, including other users behind the same NAT
Browser and SOCKS5 supportHTTP proxy auth is widely supported; SOCKS5 auth is not supported in ChromiumWorks everywhere, because the client sends no credentials
Session and geo controlsOften encoded in the username on rotating gatewaysUsually set through ports, endpoints or dashboard settings instead (varies by provider)
Breaks whenPassword is rotated, mistyped or contains unescaped special charactersYour public IP changes (dynamic ISP address, new cloud instance, VPN)
Best forDevelopers, distributed scrapers, anything that movesFixed servers, office gateways and software that can't send credentials

The username as a control panel on rotating gateways

On rotating residential and mobile networks, the username often does more than identify you. Many backconnect gateways let you append parameters to the username to choose a country, pin a sticky session or set how long that session should last. The exact syntax is entirely provider-specific (separators, parameter names and allowed values differ from one network to the next), so always copy the format from your provider's documentation rather than guessing.

This has two practical consequences. First, if you rely on per-request targeting or sticky sessions, user:pass is often the more flexible method, because one gateway address can behave many different ways depending on the username you send. Whitelisted access usually exposes those options through different ports or endpoints instead, and some options may not be available at all. Second, a malformed parameter looks exactly like a wrong password: the proxy returns 407 (or a SOCKS5 authentication failure), not a helpful "unknown country" message. When a working setup suddenly fails after you add targeting, strip the parameters back to the bare username and test again. Our guide to how rotating proxies work explains sessions and rotation in more depth.

Why SOCKS5 with a password often fails in Chrome, Puppeteer and Playwright

This is the single most common authentication surprise, and it isn't a bug in your code. Chromium's networking documentation states plainly that no authentication methods are supported for SOCKSv5 in Chrome, even though the protocol defines them. Chrome, Edge and every automation tool that drives Chromium inherit that limitation. Chromium's docs also note that it does not use credentials embedded in manual proxy settings; proxy credentials go through its normal authentication flow, which exists for HTTP-style proxies.

The automation frameworks follow from that. Playwright's network documentation says you can optionally specify a username and password for an HTTP(S) proxy, and describes SOCKSv5 support without that option. In Puppeteer and Selenium, credentials for an HTTP proxy are typically supplied through the browser's authentication flow (for example Puppeteer's page.authenticate()), which doesn't apply to a SOCKS5 handshake.

If you need a password-protected proxy in a Chromium-based tool, you have three clean options:

  1. Use the provider's HTTP endpoint instead. Most providers expose the same pool over HTTP and SOCKS5. For browser automation, HTTP with user:pass is the path of least resistance.
  2. Switch that machine to IP whitelisting. With no credentials to send, the SOCKS5 limitation disappears.
  3. Run a local forwarder. A small proxy on 127.0.0.1 accepts unauthenticated connections from the browser and forwards them upstream with credentials. It works, but it's one more moving part to secure: bind it to localhost only, never to a public interface.

Command-line tools and HTTP libraries are a different story. curl, Python's requests (with the SOCKS extra installed) and the common Node.js SOCKS agents can all send RFC 1929 credentials. The limitation is specific to Chromium. Our Puppeteer proxy guide and Selenium proxy guide show working authenticated setups.

Don't "fix" it by putting the password in the URL

Passing --proxy-server=socks5://user:pass@host:port to Chrome doesn't make Chrome authenticate. Chromium doesn't support SOCKS5 authentication, so the connection fails, and the password now sits in your process list and shell history as well.

The shared-IP trap: NAT, CGNAT and cloud egress

IP whitelisting assumes that one public IP equals one trusted machine. On many networks that assumption is false.

Diagram: MANY DEVICES funnel through a router with ONE PUBLIC IP into a WHITELIST shield marked with a warning triangle, then on to the PROXY
Every device that shares your public egress IP passes the whitelist check, not just the machine you meant to authorize.

Office and home NAT

Behind a typical router, every device on the network shares one public address. Whitelist your office IP and every laptop, phone and guest device in the building can use your proxy plan, and burn your bandwidth, without a password. That may be what you want for a team; just be aware that the access boundary is the network, not the person.

Carrier-grade NAT

Many mobile carriers and some home ISPs use carrier-grade NAT (CGNAT), where many customers share a pool of public addresses. Whitelisting an address in that pool can authorize strangers you've never met, and the address you saw a minute ago may not be the one you leave from next time. If your connection is behind CGNAT, IP whitelisting is a poor fit; use credentials.

Cloud instances and serverless

Cloud servers usually get a public IP that changes when the instance is recreated unless you reserve a static one. Serverless functions and many CI runners leave through large shared address ranges you can't pin down at all. For those environments, either route egress through a fixed NAT gateway with a reserved address and whitelist that, or use user:pass.

Dynamic home IPs and VPNs

Residential ISPs often rotate customer addresses. The day your ISP hands you a new IP, the proxy starts refusing connections and nothing in your code changed. Turning on a VPN has the same effect, because your egress becomes the VPN server's address. If you whitelist from home, re-check your public IP whenever the proxy suddenly stops working.

Setting up each method in common tools

The examples below use placeholder hosts and credentials. Replace them with the values from your provider's dashboard.

curl

# Credentials in the proxy URL
curl -x "http://USERNAME:PASSWORD@gate.example.net:8000" https://httpbin.org/ip

# Credentials as a separate option
curl -x "http://gate.example.net:8000" -U "USERNAME:PASSWORD" https://httpbin.org/ip

# SOCKS5 with credentials, DNS resolved by the proxy
curl -x "socks5h://USERNAME:PASSWORD@gate.example.net:1080" https://httpbin.org/ip

# IP whitelisting: no credentials at all
curl -x "http://gate.example.net:8000" https://httpbin.org/ip

curl URL-decodes credentials in the proxy string, so a password containing @ must be written as %40 and a colon as %3a. The curl documentation also warns that values passed with --proxy-user can briefly appear in process listings, and recommends reading sensitive data from a file rather than the command line. More patterns are in our curl proxy guide.

Python requests

import os
from urllib.parse import quote
import requests

user = os.environ["PROXY_USER"]
password = quote(os.environ["PROXY_PASS"], safe="")  # escape @, :, / and friends
proxy = f"http://{user}:{password}@gate.example.net:8000"

resp = requests.get(
    "https://httpbin.org/ip",
    proxies={"http": proxy, "https": proxy},
    timeout=20,
)
print(resp.status_code, resp.text)

The requests documentation shows the http://user:password@host/ syntax for proxy Basic auth and warns that storing usernames and passwords in environment variables or version-controlled files is a security risk. For SOCKS5, install the extra (pip install "requests[socks]") and use a socks5h:// URL. See how to use proxies with Python requests for sessions, retries and rotation.

Playwright

import { chromium } from 'playwright'; // ES module, so top-level await works

const browser = await chromium.launch({
  proxy: {
    server: 'http://gate.example.net:8000',
    username: process.env.PROXY_USER,
    password: process.env.PROXY_PASS,
  },
});
const page = await browser.newPage();
await page.goto('https://httpbin.org/ip');
console.log(await page.textContent('body'));
await browser.close();

With IP whitelisting, drop the username and password fields and keep only server. That is also the setup that makes a socks5:// server usable in Chromium.

Node.js HTTP clients

import axios from 'axios';
import { HttpsProxyAgent } from 'https-proxy-agent';

const user = encodeURIComponent(process.env.PROXY_USER);
const pass = encodeURIComponent(process.env.PROXY_PASS);
const agent = new HttpsProxyAgent(`http://${user}:${pass}@gate.example.net:8000`);

const res = await axios.get('https://httpbin.org/ip', { httpsAgent: agent, proxy: false });
console.log(res.data);

Setting proxy: false stops Axios from applying its own proxy handling on top of the agent. Node's built-in fetch doesn't accept an agent option and needs a different setup. Our Node.js proxy guide covers Axios, fetch and Got with tested code.

Storing proxy credentials safely

A leaked proxy password is a billing problem first and a reputation problem second: someone else spends your bandwidth, and whatever they do through your account is tied to you. A few habits prevent most leaks.

  • Keep credentials out of source code. Never hard-code them, and add .env files to .gitignore. If a password has ever been committed, rotate it; deleting the line doesn't remove it from history.
  • Prefer a secrets manager in production. Environment variables are better than hard-coding but can leak through crash dumps, debug pages and child processes. CI platforms and cloud providers offer secret stores that inject values at runtime.
  • Keep them out of logs. Proxy URLs with embedded credentials end up in exception messages and request logs surprisingly often. Redact the user-info part before logging any proxy URL.
  • Use sub-users where the provider offers them. Separate credentials per project, teammate or server mean you can revoke one without breaking everything, and usage is easier to attribute.
  • Rotate on a schedule and on departures. Change passwords when someone leaves the team or a laptop goes missing, and periodically anyway.
  • Keep the whitelist short. Remove addresses you no longer use. An old office IP or a decommissioned server address on your allowlist is an open door for whoever gets that address next.
  • Protect the hop to the proxy. On untrusted networks, use the provider's HTTPS proxy endpoint if one exists, or route the traffic through a tunnel you control, so credentials aren't sent in the clear.

A sensible default

Use user:pass from a secrets store for anything that moves (laptops, CI, serverless, distributed scrapers), and IP whitelisting for a small number of fixed servers with reserved addresses. Many teams run both on the same account.

Troubleshooting authentication failures

Authentication errors are noisy but easy to narrow down once you know which method is in play.

You get 407 Proxy Authentication Required

  • Check the username and password character by character, including any session or country parameters added to the username.
  • Percent-encode special characters in passwords embedded in URLs. An unescaped @ or : silently splits the URL in the wrong place.
  • Confirm you're pointing at the right gateway and port for your plan. Residential, datacenter and mobile products often have different endpoints.
  • Check in the dashboard that the plan is active and has bandwidth left, so you can rule out an account problem before debugging code.

SOCKS5 connections drop immediately

  • If the client is Chromium-based, the cause is almost certainly the missing SOCKS5 auth support described above. Switch to HTTP or whitelisting.
  • In other clients, an immediate close usually means no acceptable method was offered (you sent no credentials to a proxy that requires them) or the credentials were rejected.

Whitelisting worked yesterday and fails today

  • Check your current public egress IP without the proxy and compare it with the dashboard. Dynamic IPs, new cloud instances and VPNs are the usual culprits.
  • If you have just edited the whitelist, wait briefly and retry, since a change may not reach every gateway instantly.
  • If your network has both IPv4 and IPv6, make sure the address family your client actually uses is the one on the list.

For a full decoder of status codes and connection errors, see proxy error codes explained, and use the checks in how to test a proxy to confirm the exit IP once authentication succeeds.

Which method should you choose?

Use this as a quick decision guide:

  • Your code runs on a laptop, in CI, on serverless or across many machines: username/password.
  • You need sticky sessions or per-request country targeting on a rotating gateway: username/password, unless your provider documents equivalent options for whitelisted access.
  • You're driving Chrome, Puppeteer or Playwright through SOCKS5: IP whitelisting, or switch to the HTTP endpoint with user:pass.
  • You have a few fixed servers with reserved public IPs: IP whitelisting is simple and keeps secrets out of your code.
  • The software can't send proxy credentials at all: IP whitelisting.
  • You're behind CGNAT, a shared office network or a VPN: username/password, so access isn't granted to everyone who shares your address.

When you compare providers, check which authentication methods each plan supports, how many whitelist entries you get, whether sub-users are available and whether there is an HTTPS proxy endpoint. Our guide on how to choose a proxy provider lists the other questions worth asking before you buy.

Conclusion

Proxy authentication comes down to a trade-off between portability and secret-free simplicity. Username/password works from anywhere and gives you fine-grained control on rotating gateways, but the credentials are a secret you have to keep out of code, logs and untrusted networks. IP whitelisting keeps secrets out of your client entirely and works with software that can't authenticate, including Chromium over SOCKS5, but it trusts every device behind the whitelisted address and breaks when that address changes. Pick the method that matches where your code runs, protect whichever secret you end up with, and when a request fails, start by asking which of the two checks said no.

Frequently asked questions

Proxy authentication is how a proxy decides whether a connection is allowed to use it. Paid providers either check a username and password sent by your client or check the public IP address the connection comes from against an allowlist you registered. Both methods tie traffic to your account and keep strangers off the network.

Neither is automatically more secure. IP whitelisting keeps passwords out of your code and off the wire, but it trusts every device that shares the whitelisted IP. Username and password works anywhere, but the credentials can leak through code, logs or an unencrypted connection to the proxy.

Chromium's networking documentation states that no authentication methods are supported for SOCKSv5 in Chrome, even though the protocol defines them. Chrome, Edge, Puppeteer and Playwright's Chromium inherit this. Use the provider's HTTP endpoint with credentials, switch to IP whitelisting, or run a local forwarder bound to localhost.

A 407 means the proxy itself refused the request because credentials were missing or wrong. Check the username, password and any session or country parameters, percent-encode special characters in passwords placed in URLs, and confirm you are using the right gateway and port for your plan.

Add the public egress IP that the internet sees for the machine running your code, not a private address such as 192.168.x.x or 10.x.x.x. Find it by calling an IP-echo service without the proxy from that machine. If the address changes, the whitelist must be updated.

It works poorly. Carrier-grade NAT shares public addresses among many customers, so whitelisting one can authorize strangers, and your address may change between connections. On mobile data, CGNAT connections and VPNs, username and password authentication is the better choice.

Not by default. HTTP proxy Basic auth sends username and password in Base64, which is an encoding rather than encryption, and SOCKS5 username/password auth sends them in cleartext. Even when the target site uses HTTPS, the CONNECT request to a plain HTTP proxy is unencrypted. An HTTPS proxy endpoint, where offered, encrypts the hop to the proxy.

When credentials are embedded in a proxy URL, percent-encode reserved characters, for example @ becomes %40 and : becomes %3A. In Python use urllib.parse.quote with safe set to an empty string, and in Node.js use encodeURIComponent. Alternatively pass credentials through a separate option such as curl's --proxy-user.

Found this useful? Share it.