How to use a proxy with cURL
To send a cURL request through a CleanProxies proxy, pass the proxy with -x: curl -x http://USERNAME:PASSWORD@HOST:PORT https://api.ipify.org. For SOCKS5, use -x socks5h://USERNAME:PASSWORD@HOST:PORT so DNS is resolved on the proxy side too.
What you need
- An active CleanProxies plan: static ISP proxies for fixed US IPs, or rotating residential / mobile proxies for pools. The trial works too.
- Your credential line from the dashboard's proxy manager: host (or IP), port, username and password.
- cURL itself. It ships with macOS, Windows 10 and later, and almost every Linux distribution; run
curl --versionto check. - A terminal. On Windows, call
curl.exein PowerShell, becausecurlthere can be an alias forInvoke-WebRequest.
New to proxies? For the overview, read Using proxies with cURL, Python and Node.js and SOCKS5 vs HTTP proxies. This guide goes deeper on cURL only.
Your CleanProxies credentials
| Product | Line in your dashboard | Notes |
|---|---|---|
| Static ISP proxies | IP:PORT:USER:PASS | One line per dedicated IP. With IP whitelisting turned on, the line is just IP:PORT and no password is sent. |
| Rotating residential and mobile | HOST:PORT:USER:PASS | Generated in the proxy manager. The username carries the location and session you pick, so generate a new list to change them. |
Most tools want the same details as a URL: http://USERNAME:PASSWORD@HOST:PORT for HTTP(S) or socks5://USERNAME:PASSWORD@HOST:PORT for SOCKS5. The examples on this page use those placeholders; copy the host, port, username and password from your CleanProxies dashboard. To convert a whole list at once, paste it into the proxy list formatter.
How to set up CleanProxies in cURL
- 1
Copy one proxy line
Open the proxy manager in your CleanProxies dashboard and copy a line. ISP lines look likeIP:PORT:USER:PASS; residential and mobile lines look likeHOST:PORT:USER:PASS. - 2
Turn it into a proxy URL
Reorder it ashttp://USERNAME:PASSWORD@HOST:PORT, or pick theUSER:PASS@IP:PORTformat in the dashboard so you only add the scheme. - 3
Send a test request
Runcurl -x http://USERNAME:PASSWORD@HOST:PORT https://api.ipify.org. The response is the IP address websites see. - 4
Compare with your own IP
Runcurl https://api.ipify.orgwithout-x. If the two addresses differ and the first one is your proxy's, you are connected.
cURL proxy commands for HTTP(S) and SOCKS5
Use the http:// proxy scheme for both HTTP and HTTPS websites. For an https:// target, cURL opens a CONNECT tunnel through the proxy and TLS runs end to end between cURL and the website, so you never need -k or --insecure because of the proxy.
curl -x http://USERNAME:PASSWORD@HOST:PORT https://api.ipify.orgcurl -x http://HOST:PORT -U USERNAME:PASSWORD https://api.ipify.orgcurl -x socks5h://USERNAME:PASSWORD@HOST:PORT https://api.ipify.org
# the same, with long-form flags
curl --socks5-hostname HOST:PORT --proxy-user USERNAME:PASSWORD https://api.ipify.org-U is short for --proxy-user; it keeps the password out of the proxy URL, which helps when the password contains @ or :. Inside a URL, percent-encode those characters instead (@ becomes %40).
Set the proxy once: environment variables and .curlrc
cURL reads the http_proxy, https_proxy and no_proxy environment variables. It accepts HTTPS_PROXY in upper case but ignores upper-case HTTP_PROXY for security reasons, so the lower-case names are the safe choice.
export http_proxy="http://USERNAME:PASSWORD@HOST:PORT"
export https_proxy="http://USERNAME:PASSWORD@HOST:PORT"
export no_proxy="localhost,127.0.0.1"
curl https://api.ipify.orgproxy = "http://HOST:PORT"
proxy-user = "USERNAME:PASSWORD"Skip the proxy for a single call with --noproxy '*'.
Test a whole proxy list from the shell
Save your ISP lines to proxies.txt (one IP:PORT:USER:PASS per line) and loop over them. -m 15 caps each request at 15 seconds, and read puts everything after the third colon into the password, so passwords with colons survive.
while IFS=: read -r host port user pass; do
printf "%s:%s -> " "$host" "$port"
curl -s -m 15 -x "http://$user:$pass@$host:$port" https://api.ipify.org || printf "failed"
echo
done < proxies.txtcurl -s -o /dev/null -x http://USERNAME:PASSWORD@HOST:PORT \
-w "status %{http_code} connect %{time_connect}s total %{time_total}s\n" \
https://www.example.comStatic ISP vs rotating residential in cURL
Static ISP proxies
Each ISP line is one dedicated US IP on a real carrier ASN. The same line always exits from the same address, so a loop over your list is how you spread requests across IPs.
Rotating residential proxies
Generate a rotating list and every new connection through the gateway can leave from a different residential IP; run the test command twice to see it change. Generate a sticky list and the same username keeps one IP for the session length you chose.
Verify your exit IP
api.ipify.org returns only the IP address. Add -v to see the proxy handshake: a working HTTP(S) proxy prints CONNECT api.ipify.org:443 followed by HTTP/1.1 200 Connection established.
curl -v -x http://USERNAME:PASSWORD@HOST:PORT https://api.ipify.orgOpen What is my IP? through the proxy to see the address and headers a website receives, or paste up to ten lines into the free proxy checker to test connectivity, latency and exit IP before you start.
Troubleshooting cURL proxy errors
| Problem | Likely cause | Fix |
|---|---|---|
| CONNECT tunnel failed, response 407 | Wrong username or password, or an ISP proxy set to IP whitelisting from a different IP. | Copy the line again from the dashboard. If you use IP whitelisting, authorize the public IP of the machine running cURL. |
| curl: (7) Failed to connect / (28) timed out | Wrong port, a firewall blocking outbound traffic, or an expired plan. | Check the port and that the plan is active. Try from another network to rule out a local firewall. |
| curl: (35) or (60) SSL errors | Usually an https:// proxy scheme against an HTTP proxy port, or a corporate TLS inspector. | Use http:// as the proxy scheme; the tunnel still carries HTTPS end to end. Don't add -k. |
| SOCKS5 works but DNS goes out locally | socks5:// resolves the hostname on your machine. | Use socks5h:// or --socks5-hostname so the proxy resolves it. |
| Your own IP comes back | The proxy wasn't applied (for example --noproxy or a no_proxy match). | Pass -x explicitly and check env | grep -i proxy. |
Still stuck? Our 24/7 support team answers fast: contact us with the error and the line you used (leave the password out).
cURL proxy FAQs
Use http:// for CleanProxies HTTP(S) proxies. HTTPS websites still work: cURL sends a CONNECT request and the TLS session runs end to end through the tunnel. An https:// proxy scheme means TLS to the proxy itself, which is a different setup.