How to Use Socks5 Proxy in Curl

Curl has the best proxy support among many HTTP clients and download tools. This is how you use a socks5 proxy and also resolve hostname in the URL using the socks5 proxy. For some use case, resolving hostname via the proxy is essential.

Suppose you have a socks5 proxy running on localhost:8001.

In curl >= 7.21.7, you can use

In curl >= 7.18.0, you can use

Many tools use libcurl internally or use curl command in their installer script. If it’s difficult to modify the command line itself, you can set proxy using environment variables.

If you want to overwrite system proxy settings, you may also need to set two more variables:

Note that http_proxy is lower case, the other two is upper case.

 

来源: How to Use Socks5 Proxy in Curl

Scroll to top