Using Proxies With cURL: A Quick Guide

Using Proxies With cURL: A Quick Guide

cURL is one of the most common command-line tools for making HTTP requests, and it has proxy support built directly into its flags.

Basic HTTP proxy usage

Adding the -x flag followed by the proxy address and port routes the request through that proxy — for example, curl -x http://1.2.3.4:8080 https://example.com sends the request via the specified proxy instead of directly.

Using SOCKS5

For a SOCKS5 proxy, prefix the address with socks5:// in the -x flag instead of http://, which tells cURL to negotiate the SOCKS protocol rather than treating it as a standard HTTP proxy.

Adding authentication

If the proxy requires credentials, the -U flag followed by username:password supplies them, or you can embed them directly in the proxy URL passed to -x, similar to how it works in browser and code-based setups.