How to Test a Proxy With the curl Command
curl is the quickest way to see whether a proxy works. This guide covers the options that matter, how to read the output and how to avoid common mistakes.
9 min readUpdated Nov 13, 2026By XPASS Editorial Team

When a proxy does not behave the way you expect, the quickest way to find out why is to take your application out of the picture and send a single request from the command line. The tool for that is curl, which is installed by default or easily available on macOS, Linux and current versions of Windows. It supports HTTP and SOCKS proxies, shows you what is happening at every stage, and gives results that are easy to share with a colleague or a support team.
This guide walks through the options that matter, explains how to read the output, shows a repeatable test routine, and points out the mistakes people make most often. Use proxies only for lawful work that respects the terms of the sites you visit and the laws where you live.
Why curl is a good test tool
Applications add layers: libraries, frameworks, retries, certificate stores, connection pools. When something fails, it is hard to know which layer is responsible. curl is small and predictable. If a request works in curl and fails in your application, the proxy is almost certainly fine and the difference lies in how your application is configured. If it fails in both, the problem is in the settings, the network path or the proxy itself.
curl also prints the details of each stage when asked. That includes name resolution, the connection to the proxy, the tunnel request for HTTPS, the TLS handshake and the response headers. The MDN overview of proxy servers and tunneling explains why HTTPS through an HTTP proxy uses a CONNECT tunnel, which is what you will see in the verbose output.

The values you need
Before you type anything, have these four things ready from your plan page:
- Host: the proxy gateway name or address.
- Port: the port that matches the protocol you plan to use.
- Protocol: HTTP or SOCKS5.
- Credentials: username and password, if the proxy requires them.
If you are unsure whether the port is reachable at all, run through the checks in the guide on verifying a proxy port before you start first. It takes a couple of minutes and rules out the most common causes of failure.
The basic commands
HTTP proxy
curl -x "http://USERNAME:PASSWORD@HOST:PORT" https://example.com/
The -x option (also written --proxy) tells curl which proxy to use. The part before the proxy host is the credentials. If the proxy needs no authentication, drop the USERNAME:PASSWORD@ part.
SOCKS5 proxy
curl --proxy "socks5h://USERNAME:PASSWORD@HOST:PORT" https://example.com/
With socks5:// curl resolves the destination host name on your computer and sends the IP address to the proxy. With socks5h:// the proxy resolves the name. Using socks5h is usually what you want, because the destination name is then looked up from the proxy's side and does not go through your local DNS. The authentication step for SOCKS5 is described in RFC 1928.
Passing credentials separately
You can also give credentials with an option instead of putting them in the URL:
curl -x "http://HOST:PORT" --proxy-user "USERNAME:PASSWORD" https://example.com/
This avoids URL-encoding problems with special characters in the password, because the value is not parsed as part of a URL.
Useful options
| Option | What it does |
|---|---|
-v |
Shows each stage and the headers sent and received |
-I |
Requests only the headers, which is quick and light |
-s |
Silent mode, hides the progress meter |
-S |
With -s, still shows errors |
--max-time 20 |
Stops the whole request after 20 seconds |
--connect-timeout 10 |
Stops if the connection is not made within 10 seconds |
-w "%{http_code}\n" |
Prints the HTTP status code after the transfer |
-o /dev/null |
Discards the body (use NUL on Windows) |
-L |
Follows redirects |
--proxy-user |
Passes the proxy credentials separately |
A good starting combination for a quick check is:
curl -sS -o /dev/null -w "%{http_code}\n" --connect-timeout 10 --max-time 20 -x "http://USERNAME:PASSWORD@HOST:PORT" https://example.com/
It prints only the status code and shows an error message if anything fails. A 200 means the path, the protocol and the login all worked.
A few more habits make these options work harder for you. Put --connect-timeout and --max-time into every test, even the quick ones, because a command that hangs for two minutes teaches you nothing and tempts you to start changing settings at random. Use -I when you only want to know whether a path answers, since some servers handle a header-only request differently from a full download, and note that difference rather than treating it as a failure. Add -L only when you actually expect a redirect, so that an unexpected redirect shows up as a result instead of being hidden. Finally, keep your options in the same order every time. A routine that always reads the same way is much easier to compare across days and across colleagues.
Reading the verbose output
Add -v and read the lines that begin with an asterisk, a greater-than sign or a less-than sign.
- Lines starting with
*are curl's own messages, such as "Trying ..." and "Connected to ...". This tells you whether the TCP connection to the proxy was made. - Lines starting with
>are what curl sent. For HTTPS you will see aCONNECTline asking the proxy to open a tunnel to the destination. - Lines starting with
<are what came back. After the tunnel request, you should see a200response from the proxy. Then the TLS handshake happens, followed by the real request and response.
Where the output stops tells you where the chain breaks:
| Last thing you see | Likely meaning |
|---|---|
| "Could not resolve host" | The host name cannot be resolved |
| "Trying ..." and nothing else | Cannot reach the proxy, often a firewall or wrong address |
| "Connection refused" | The host answered but nothing listens on that port |
407 Proxy Authentication Required |
The proxy rejected the credentials |
200 for CONNECT, then a long pause |
The tunnel opened but the destination is slow or unreachable |
| A TLS error after the tunnel | The destination or a certificate problem, not the proxy login |
Status code meanings follow the HTTP semantics in RFC 9110. For timeouts in particular, the article on what a proxy timeout means and the basic fixes goes deeper.
Confirm the exit IP
A successful response only shows that traffic flowed. To prove that it went through the proxy, ask a service that returns the caller's address:
curl https://api.ipify.org
curl -x "http://USERNAME:PASSWORD@HOST:PORT" https://api.ipify.org
The first command shows your own address, the second the proxy's exit address. They should be different. If they match, curl is not using the proxy, for example because the URL was malformed or an option was misspelled.
Any similar service works. Choose one you trust and avoid sending sensitive data to it.
A repeatable test routine
Use the same routine each time, so results are comparable:
- Run the plain request without a proxy to confirm that your own connection works.
- Run the same request through the proxy with
-vand read the output. - Run the exit-IP check through the proxy.
- Repeat the proxy request three times to see whether it is consistent.
- If you use session labels or country options in the username, test each variation separately. Differences between them are easier to spot in a command line than inside an application.
- Save the successful command, with the password replaced by a placeholder, in your project notes.
A short decision rule helps when results are mixed. If step 1 fails, stop and fix your own connection before touching anything else. If step 1 works but step 2 fails every time, the cause is in the proxy settings or credentials. If step 2 works once and fails the next time, suspect timing, a session that expired or a limit on the plan, and test again at another hour. If step 3 shows your own address, the request never used the proxy, so read the command again before reading anything else. Write the outcome of each step in one line in your notes, because a clear sequence of ordinary lines is what a support team needs to see.
Common mistakes in this routine are worth listing. People change two things at once, such as the port and the protocol, and then cannot tell which change mattered. They test only against a heavy website, where a slow page looks like a slow proxy. They forget that quotes around the proxy URL matter in some shells, because characters in a password can be read as shell syntax before curl ever sees them. And they stop at the first success, when three or four consistent results are a far better basis for trust.
A plain example
Suppose you received an HTTP proxy at proxy.example.net on port 8000, with a username and password.
curl -sS -o /dev/null -w "%{http_code}\n" https://example.com/prints200. Your own connection works.- The same command with
-x "http://USERNAME:PASSWORD@proxy.example.net:8000"prints407. The proxy is reachable and rejects the credentials. - You notice that the password contains the character
@. You rewrite the command with--proxy-user "USERNAME:PASSWORD"and keep the host separate. It now prints200. - The exit-IP check shows an address different from your own.
The lesson is that the same credentials can fail in one form and work in another when special characters meet URL parsing.
Limits and what to watch for
- curl proves little about your application. It confirms that the proxy works, not that your code uses it. Compare settings if the application still fails.
- Environment variables can interfere. curl respects variables such as
http_proxy,https_proxyandno_proxy. A leftover variable can send traffic somewhere you do not expect. Use-vto check, or run with--noproxycarefully to rule it out. - Shell history stores passwords. Commands with credentials stay in your history. Use environment variables for routine tests, clear sensitive entries, and never post a raw command in a public place.
- Certificate checks matter. Avoid the
-koption that disables verification. If you see a certificate error, find out why instead of switching the check off. - One success is not proof of stability. Repeat the test at different times.
- Respect the target. Test against a site you own or a neutral test address, keep request volume low, and follow the destination's terms and the law that applies to you.
- Authentication in managed environments differs. Company proxies sometimes use methods other than a simple username and password. See the guide on proxy authentication in enterprise tools for those cases.
Quick troubleshooting table
| Observation | First thing to try |
|---|---|
| No output, command hangs | Add --connect-timeout 10 and -v, then check host and port |
| 407 | Check credentials, try --proxy-user |
| 502 or 503 from the proxy | Retry, try another session or exit, then contact support if it persists |
| Works in curl, fails in the application | Compare the settings the application really sends |
| Exit IP equals your own | Check the proxy URL and environment variables |
Summary
curl lets you test a proxy in isolation. Use -x for an HTTP proxy and --proxy with socks5h:// for SOCKS5, add -v to see each stage, set timeouts so a hang stops on its own, and confirm the exit IP with an address-echo service. Read where the output stops to find the failing step, pass credentials with --proxy-user when special characters cause trouble, and keep passwords out of shared logs. Test lawfully and within the rules of the sites involved. When you are ready to look at available options, the XPASS Proxy page is a good place to start.
Frequently asked questions
What is the basic curl command to test an HTTP proxy?
Use the -x option followed by the proxy URL, for example curl -x http://USERNAME:PASSWORD@HOST:PORT https://example.com/. Add -v to see each stage and --max-time to stop a request that hangs.
How do I test a SOCKS5 proxy with curl?
Use --proxy with a socks5h:// URL, such as curl --proxy socks5h://USERNAME:PASSWORD@HOST:PORT https://example.com/. The h in socks5h means the proxy resolves the destination host name instead of your computer.
How can I confirm that curl is really using the proxy?
Request an address-echo service through the proxy and compare the result with the same request made without the proxy. The two IP addresses should differ. The verbose output also shows the connection to the proxy host.
What does a 407 response mean?
It means the proxy was reached but needs valid credentials. Check the username, the password, special characters that need encoding, and whether the proxy expects a different authentication method.
Is it safe to put the password in the command?
It works, but the password can remain in your shell history and be visible to other users of the machine. For regular use, store credentials in environment variables or a protected configuration file, and never paste them into shared chats.
References
About the author

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 plansKeep reading

Proxy Guides
How to Check a Proxy Port Before You Start Using It
A quick port check saves hours of confusing errors. This guide shows how to test reachability, protocol and login in a few minutes, step by step.
9 min read

Proxy Guides
How to Configure Proxy Authentication in Enterprise Tools
A practical guide to proxy authentication: username and password, IP allowlisting, the 407 response, and how to configure common enterprise tools correctly.
10 min read

Proxy Guides
What a Proxy Timeout Means and How to Fix It
A timeout does not tell you what failed, only that no answer arrived in time. This guide shows how to narrow down the cause and apply basic fixes in order.
9 min read