Guide · curl

Using a proxy with curl

curl is the fastest way to check whether a proxy is working, independent of any browser or extension. The curl command is built into Linux, macOS, and Windows 10, 11. This guide covers command examples, how to read output to troubleshoot errors, and how to set a default proxy for all commands.

Author: Bùi Toàn · Updated: 19/11/2026

Basic commands

  • From the ip:port:user:pass format, run: curl -x http://IP:PORT -U user:pass https://api.ipify.org
  • Or combine into a single string: curl -x http://user:pass@IP:PORT https://api.ipify.org
  • The output must be the proxy IP. Seeing your ISP IP means the request did not go through the proxy.
  • To also check the country: replace the destination URL with https://ipinfo.io/json.
  • If the proxy runs in SOCKS5 or HTTP + SOCKS5 mode: curl -x socks5h://user:pass@IP:PORT https://api.ipify.org (socks5h lets the proxy resolve domain names), or curl --socks5-hostname IP:PORT -U user:pass https://api.ipify.org.

On Windows

In PowerShell 5.1, "curl" is an alias for Invoke-WebRequest, not the real curl. Use curl.exe instead of curl: curl.exe -x http://IP:PORT -U user:pass https://api.ipify.org. In Command Prompt (cmd) and PowerShell 7 or higher, curl is the real curl.

How do you use curl with special characters in the proxy password?

When using the user:pass@IP format, special characters such as @ : / # % in the password must be URL-encoded—for example, @ becomes %40 and # becomes %23. Using -U "user:pass" (enclosed in double quotes) requires no encoding and reduces errors. On Linux and macOS, use single quotes if the password contains $ or !.

How do you read curl output to diagnose proxy errors?

Add -v to inspect each step: the "200 Connection established" line indicates the proxy accepted the connection, while the error messages below show whether the issue stems from credentials, ports, network, or the destination site.

Add -v for verbose details

For HTTPS sites, curl sends a CONNECT request to the proxy. The line "< HTTP/1.1 200 Connection established" means the proxy accepted the connection. The line "407 Proxy Authentication Required" indicates an incorrect username or password.

Failed to connect … Connection refused

Connection to IP:port was immediately refused: wrong port, proxy expired, or inactive. See the guide on connection refused errors.

Connection timed out

No response received: incorrect IP, network issues, or a firewall blocking the port. Add --connect-timeout 10 to avoid waiting too long.

CONNECT tunnel failed, response 502 or 503

The proxy is running but failed to establish a connection to the destination site. Try another website to determine whether the issue is with the target site or the proxy.

Set a default proxy

Set environment variables so all curl commands (and many other tools) automatically use the proxy: export https_proxy="http://user:pass@IP:PORT" and export http_proxy="$https_proxy" on Linux and macOS. Bypass the proxy for a single command using --noproxy "*". Alternatively, add the line proxy = "http://user:pass@IP:PORT" to your ~/.curlrc file.

No proxy yet? Buy dedicated proxies with automatic activation

Dedicated IPv4 proxies in 9 countries from 20.000₫/IP/month when purchasing from 2.000 IPs (39.000₫ for 1 IP), plus Vietnam and US static ISP proxies. HTTP(S) and SOCKS5 with user and password, unlimited bandwidth, automatically provisioned after payment. Vietnam proxies currently use the HTTP(S) protocol; SOCKS5 is not yet available.

Buy proxies now

Frequently Asked Questions

Why does the https_proxy value still start with http://?+

The prefix specifies how curl connects to the proxy, not to the destination site. When communicating with the ONET proxy over HTTP, HTTPS sites are still reachable via the CONNECT method. With SOCKS5, the value starts with socks5h://.

Can I use --socks5 with ONET proxies?+

Yes, when the proxy is operating in SOCKS5 or HTTP + SOCKS5 mode: curl --socks5-hostname IP:PORT -U user:pass https://api.ipify.org, or -x socks5h://user:pass@IP:PORT. Use socks5h or --socks5-hostname so that domain names are resolved on the proxy side. Note that Vietnam proxies currently use the HTTP(S) protocol only; SOCKS5 is not yet available.