Skip to content
Command-line tool

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

cURL is the fastest way to test a proxy before you wire it into a scraper, a browser or an agent. If a line works in cURL, any failure later is in your tool's configuration, not in the proxy.
  • 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 --version to check.
  • A terminal. On Windows, call curl.exe in PowerShell, because curl there can be an alias for Invoke-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

Every CleanProxies product works over HTTP(S) and SOCKS5. This is what the dashboard gives you.
ProductLine in your dashboardNotes
Static ISP proxiesIP:PORT:USER:PASSOne line per dedicated IP. With IP whitelisting turned on, the line is just IP:PORT and no password is sent.
Rotating residential and mobileHOST:PORT:USER:PASSGenerated 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. 1

    Copy one proxy line

    Open the proxy manager in your CleanProxies dashboard and copy a line. ISP lines look like IP:PORT:USER:PASS; residential and mobile lines look like HOST:PORT:USER:PASS.
  2. 2

    Turn it into a proxy URL

    Reorder it as http://USERNAME:PASSWORD@HOST:PORT, or pick the USER:PASS@IP:PORT format in the dashboard so you only add the scheme.
  3. 3

    Send a test request

    Run curl -x http://USERNAME:PASSWORD@HOST:PORT https://api.ipify.org. The response is the IP address websites see.
  4. 4

    Compare with your own IP

    Run curl https://api.ipify.org without -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.

HTTP(S) proxy, credentials in the URLshell
curl -x http://USERNAME:PASSWORD@HOST:PORT https://api.ipify.org
HTTP(S) proxy, credentials as a separate flagshell
curl -x http://HOST:PORT -U USERNAME:PASSWORD https://api.ipify.org
SOCKS5 with remote DNSshell
curl -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.

Environment variables (macOS, Linux)shell
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.org
~/.curlrc (applies to every curl call)text
proxy = "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.

Check every line and print its exit IPshell
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.txt
Time a request through the proxyshell
curl -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.com

Static ISP vs rotating residential in cURL

Both products use the same setup. What changes is how long an IP stays with you.

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.

Static ISP ProxiesAs low as $0.75/IP

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.

Rotating Residential ProxiesAs low as $0.63/GB

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.

Verbose requestshell
curl -v -x http://USERNAME:PASSWORD@HOST:PORT https://api.ipify.org

Open 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

ProblemLikely causeFix
CONNECT tunnel failed, response 407Wrong 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 outWrong 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 errorsUsually 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 locallysocks5:// resolves the hostname on your machine.Use socks5h:// or --socks5-hostname so the proxy resolves it.
Your own IP comes backThe 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.

Get CleanProxies for cURL

Super clean US ISP IPs from $0.75/IP with unlimited bandwidth, rotating residential from $0.63/GB and mobile from $0.79/GB. Instant delivery, 99.9% uptime and 24/7 support.