How to Use cURL With a Proxy: -x, Auth, Env Variables, no_proxy

Rewritten as a tested reference. Every command below was run against local proxies started by the example package (an HTTP proxy with Basic authentication, a SOCKS5 proxy with authentication, an open HTTP proxy) and the output is copied from that run. The previous version repeated its configuration section three times, used placeholder hosts throughout, and contained a mangled example address; all of that is gone.
Updated 2026-10-23: added a section that sends a country-targeted request through the ScrapingAnt API, run once with proxy_country=FR.
The short answer:
curl -x http://proxy.example.com:8080 https://example.com/ # through an HTTP proxy
curl -x http://proxy.example.com:8080 --proxy-user user:pass https://example.com/ # with authentication
curl -x socks5h://user:pass@proxy.example.com:1080 https://example.com/ # SOCKS5, proxy resolves names
-x (long form --proxy) takes [scheme://][user:pass@]host[:port]; without a scheme curl assumes an HTTP proxy, and without a port it assumes 1080. The rest of this page shows what actually happens on the wire for each variant, how to set a proxy through the environment or .curlrc, how to switch it off for some hosts, and how the common failures look. Transcripts marked -v are trimmed to the proxy-related lines (a real -v prints a lot more), and non-local IP addresses are masked as <ip>. Tested with curl 8.7.1.








