Skip to content

When a proxy asks for a username and password, it is doing the same thing a hotel does when it asks for your room number: checking that you are a customer who is allowed to be here. Most proxy plans use this method, yet it is the source of many confusing problems, such as endless password prompts, error 407, and URLs that break because of a single character in a password.

This guide explains what happens behind the prompt, how HTTP and SOCKS5 proxies check credentials, where to put them in browsers, tools and scripts, and how to keep them safe. It assumes you use proxies lawfully and within the terms of the services you visit.

Why proxies ask for credentials

A proxy forwards your traffic using someone's bandwidth and network addresses. If it accepted every connection, anyone who learned the address could use it, and the provider could not tell customers apart or apply the limits of a plan. Authentication solves three practical problems:

  • Access control. Only customers with a valid plan can use the proxy.
  • Accounting. The provider can attribute usage to a specific account.
  • Abuse handling. If a credential is leaked or misused, it can be disabled without affecting other customers.

There are two common ways to authenticate. One is a username and password, which is the subject of this article. The other is authorisation by your source IP address, covered in the guide to proxy IP whitelisting. Some plans offer one, some the other, and some both.

How HTTP proxy authentication works

HTTP proxy authentication is part of HTTP itself and is defined in RFC 9110. The exchange looks like this.

  1. Your client sends a request through the proxy without credentials, or the proxy needs to check them again.
  2. The proxy answers with status 407 Proxy Authentication Required and a Proxy-Authenticate header that names the scheme it accepts, most often Basic.
  3. The client sends the request again with a Proxy-Authorization header containing the credentials.
  4. If they are valid, the proxy forwards the request. If not, it answers 407 again.

With the Basic scheme, the header holds your user name and password joined by a colon and then Base64-encoded. Base64 is an encoding, not encryption: anybody who sees the header can decode it in a moment. That is why the connection to the proxy matters. If it is plain HTTP, the credentials cross the network in a form that can be read by anyone able to observe that path. If the connection to the proxy is protected by TLS, the header is encrypted along with everything else.

For HTTPS websites, the browser sends a CONNECT request to the proxy, and the credentials travel on that request. After the tunnel is open, the encrypted session to the website passes through untouched, and the proxy does not see inside it.

Browsers handle all this for you. The first time a proxy answers 407, the browser shows a dialog and then repeats the request with the details you typed, and usually remembers them for the session.

How SOCKS5 authentication works

SOCKS5 does it differently. In the opening handshake of RFC 1928, the client lists the authentication methods it supports, and the proxy picks one. The common methods are "no authentication" and "username and password", the latter being defined in a companion document, RFC 1929. In the username and password method, the client sends the name and password in a short message, and the proxy replies with success or failure.

Two things follow:

  • There is no 407 equivalent. A failed SOCKS5 authentication simply closes the connection or returns a failure code, so the error looks like a connection problem rather than a clear "wrong password" message.
  • The credentials are sent as plain bytes inside the SOCKS handshake. There is no encoding step to protect them, so they are exposed to anyone who can watch the path to the proxy, unless that path is protected in another way.

The article on HTTP, HTTPS and SOCKS5 proxies compares the protocols in more depth, and the SOCKS5 beginner's guide shows how to test a SOCKS5 login from the command line.

Where to enter credentials

Where How
Browser dialog Enter host and port in the proxy settings; the browser asks for the user name and password on the first request.
Operating system Some systems have fields for user name and password next to the proxy host. Others prompt when a program connects.
curl curl -x http://host:port -U user:password https://example.com/ for HTTP proxies. For SOCKS5, use --socks5-hostname host:port -U user:password.
URL form http://user:password@host:port. Many libraries and tools accept a proxy written this way.
Environment variables HTTP_PROXY and HTTPS_PROXY hold the URL form. Many command-line tools read them.
Application settings Look for a proxy section with separate fields for user name and password.

The values above are placeholders. Use the details from your provider.

Special characters in passwords

When credentials are placed inside a URL, characters that have a meaning in URLs must be percent-encoded. A password with an @ sign will otherwise be cut at that point, because the first @ that appears after the credentials marks the start of the host. The common ones are:

Character Encoded form
@ %40
: %3A
/ %2F
# %23
? %3F
% %25
space %20

If you copy a password into a URL and the proxy "does not work", encoding is the first thing to check. If the tool has separate user name and password fields, you can type the password as it is, with no encoding.

A safe order for setting up a new proxy

When you set up credentials in a new tool, a fixed order saves time because it separates the causes of failure.

  1. Test the details in one simple tool first, such as curl, with the host, port, user name and password copied exactly from the provider's message.
  2. Only after that works, enter the same details in the browser profile or application you actually want to use.
  3. If the second step fails but the first works, the problem is in the second tool's settings, not in the credentials.
  4. Write down which tool, which protocol and which port worked, so the next person does not repeat the search.

This order also tells you quickly whether a failure is a wrong password, a blocked address or an unsupported protocol.

A worked example

Priya manages the online shop of a small company and wants to check the local checkout page from another region. Her provider sends a host, a port, a user name and a password. She first tests in the terminal with the HTTP form of curl and receives a 407. She rechecks the delivery message and realises she typed the letter O instead of the digit 0 in the user name. After fixing it, curl returns the page. She then enters the same details into a dedicated browser profile, where the browser asks for the credentials once and keeps them for the session. Because the tool-based test failed in a clear way, she never wasted time wondering whether the browser was at fault.

Keeping credentials safe

Proxy credentials are secrets, and a leaked pair lets someone else use your plan.

  1. Do not paste credentials into chat messages, tickets or public repositories. Keep them in a password manager.
  2. Keep them out of code. Put them in environment variables or a configuration file that is excluded from version control, instead of writing them into source files.
  3. Limit who can open the browser profile where the password is saved.
  4. Use one credential per purpose when the plan allows it, so you can retire a single one if it leaks.
  5. Rotate when in doubt. If you suspect a leak, change the password in the provider's dashboard.
  6. Prefer protected connections to the proxy when your provider offers them, because Basic authentication and SOCKS5 passwords are readable on an unprotected path.
  7. Check shell history and logs. A command with -U user:password may be saved in your shell history. Clear it or use a safer way to pass the secret.

Troubleshooting

Symptom What to check
Repeated password prompts Typos, wrong case, expired plan, or an address restriction. Retype carefully.
407 in curl The credentials were not sent or were refused. Check the -U option and the user name.
URL form fails Percent-encode special characters, or use separate fields.
Works in one tool, not another The second tool may not support credentials for that protocol.
Worked yesterday, fails today The plan may have ended, the password may have been rotated, or the allowed address may have changed.
Connection closes immediately on SOCKS5 Often a failed authentication. Retest with curl.

Reading the clues

A few habits make troubleshooting faster. Change one thing at a time. Copy and paste credentials instead of typing them, and watch for invisible characters such as a trailing space that can arrive when you copy from a chat message. Check whether the provider issued separate details for HTTP and SOCKS5, since some plans use a different port or even a different user name for each protocol. If the details worked before and fail now, look at the account page first: an ended plan, a changed password or a changed allowed address explains most sudden failures. Only after these checks is it worth contacting support, and your message will be easier to answer if it includes the tool, the protocol, the time of the failure and the exact error you saw, without the password itself.

Limits and what to watch for

A username and password prove who you are to the proxy. They do not make your traffic private, they do not hide what an unencrypted request contains from the proxy operator, and they do not change what is allowed by the sites you visit. Some clients, especially certain browsers with SOCKS5, handle credentials poorly; if that is the case, ask the provider whether another protocol or authorisation by address is offered. Do not share one credential among many people, because it makes abuse hard to trace and can breach the plan's terms. Check the plan page for the rules about simultaneous use. And as always, use proxies lawfully and respect the terms and rate limits of the websites you reach.

Summary

Proxy authentication checks that the client is a customer. HTTP proxies answer 407 and expect a Proxy-Authorization header, most often with the Basic scheme. SOCKS5 proxies run a username and password exchange in the handshake. Neither encrypts the credentials by itself, so a protected path to the proxy and careful handling of secrets matter. Enter credentials in the right place, percent-encode special characters when using URLs, test with curl first, and treat the details like any other password.

If you want to see which authentication options each plan supports, the Proxy page is the place to look.

Frequently asked questions

Why does a proxy need a username and password?

The proxy needs to know which customer is making a request, so it can allow the use that your plan covers and refuse everyone else. Without authentication, anyone who found the address could use it.

What is a 407 error?

HTTP status 407 means Proxy Authentication Required. The proxy is telling the client that it must supply valid credentials before the request can go through. It usually means the credentials are missing, wrong or expired.

Are proxy passwords encrypted when sent?

Not necessarily. HTTP Basic authentication encodes credentials but does not encrypt them, and the SOCKS5 username and password method sends them as plain bytes. They are protected only if the connection to the proxy itself is encrypted.

My password contains special characters and the proxy URL fails. Why?

Characters such as @, :, / and # have special meaning in a URL. When you put credentials inside a URL, you must percent-encode them, for example @ becomes %40. Otherwise the client reads the address wrongly.

Should I use credentials or IP authorisation?

Credentials work from any network and are easy to move between machines. Authorisation by source address avoids passwords but only works from addresses that you register. Pick the one that matches how and where you connect.

About the author

Bob Kanokphon Thongdee, founder of XPASS VPN

Bob Kanokphon Thongdee

  • Founder of XPASS VPN
  • Co-founder of eSIMonline.asia
  • More than 7 years in online marketing
  • Founder of Cojourney Visa and Cojourney Travel

Need a proxy for this?

XPASS Proxy sells residential proxy traffic by the gigabyte, with the price shown before you pay.

See proxy plans

Keep reading

Proxy Guides

HTTP Proxy vs HTTPS Proxy vs SOCKS5: What Is the Difference?

The three names sound similar but describe different things. Learn how HTTP, HTTPS and SOCKS5 proxies differ, what each can carry, and how to pick one.

10 min read

Proxy Guides

How to Set Up a Proxy with IP Whitelist Authentication

A step by step guide to IP whitelist authentication for a proxy: find your public IP, authorize it, point your browser or app at the proxy and test the result.

10 min read

Proxy Guides

How to Set Up a SOCKS5 Proxy: A Beginner's Guide

SOCKS5 is a general-purpose proxy protocol. This beginner's guide explains the parts you need, shows how to test a SOCKS5 proxy, and covers common mistakes.

9 min read