How to cURL with a Proxy

James Keenan

The automation and anonymity evangelist at Smartproxy. He believes in data freedom and everyone’s right to become a self-starter. James is here to share knowledge and help you succeed with residential proxies.

cURL is an extremely versatile library that lets you transfer data to and from servers. cURL can use proxies to access target servers, and has become the industry standard over the decades. This is why we always advise new users to test their proxy settings and gates (or endpoints) with a simple cURL string.

If you want to find out more about cURL, read this article:

  • What is cURL
  • how to curl with a proxy

    Using cURL with a proxy

    Most Windows and macOS devices come with pre-installed cURL libraries (libcurl), but most users are unaware of how to use it properly and how to cURL with a proxy.

    In reality, curling with a proxy is very simple. All it takes is a variable in the cURL syntax. There are several variables that let you set up proxies with cURL.

    Use the -x or --proxy command with:

    http_proxy [protocol://][:port] – this command will use the HTTP protocol with the proxy.
    HTTPS_PROXY [protocol://][:port] – this sets HTTPS as the protocol for the proxy.

    You can set proxy protocols through the prefix by using any of the following prefixes:

    http://
    https://
    socks4://
    socks5://
    socks4a://
    socks5h://

    [url-protocol]_PROXY [protocol://][:port] – this syntax sets the proxy protocol to the one you specify for the URL.

    Since cURL is syntax-dependent, it offers no user interaction. That means you have to define a proxy in the cURL syntax. To do this, use the command below and enter proxy information, for example:

    Curl -x gate.smartproxy:7000 https://ipinfo.io

    We use ipinfo.io in this example because it returns the proxy information and is very helpful when you want to be sure that you are using a proxy correctly.

    If you want to cURL an authentication request to Google’s ClientLogin API through a proxy, you would tweak the usual cURL with the proxy parameter, as so:

    Curl -x gate.smartproxy:7000 https://www.google.com/accounts/ClientLogin \
    [...]

    This cURL example will pull data from the API through the proxy server, and the API will only see the proxy IP address.

    Remember, you can also use the --proxy command instead of -x.

    To check a random rotating proxy on https://ipinfo.io with a cURL, use the following syntax:

    Curl -x gate.smartproxy.com:7000 https://ipinfo.io

    This syntax will send a request to ipinfo.io with the HTTPS protocol and the gate.smartproxy.com:7000 endpoint (gate). This will work only if you have whitelisted your IP address in the Dashboard.

    To check the same proxy with proxy user credentials (login:pass), you must use the -U parameter. Note that the parameter uses the capital U:

    Curl -U username:password -x gate.smartproxy.com:7000 https://ipinfo.io

    Why check proxies with cURL

    We use cURL because it is the easiest way to check your proxy endpoint setup before you start data scraping. cURL is a standing industry standard for over 20 years, which has proven stable, light and effective.

    Read these articles to learn more:

  • What is Web Scraping
  • Do you need a Selenium proxy?


  • As always, using Smartproxy lets you send unlimited concurrent requests from different IP addresses (including sticky IP sessions). This lets you web scrape quicker or pull a lot more data from public APIs.

    Read more about proxy settings in our Help documents.