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

  • smartproxy-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:

    This command will use the HTTP protocol with the proxy:

    http_proxy [protocol://][:port]

    This sets HTTPS as the protocol for the proxy:

    HTTPS_PROXY [protocol://][:port]

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


    This syntax sets the proxy protocol to the one you specify for the URL:

    [url-protocol]_PROXY [protocol://][:port]

    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

    We use 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 \ 

    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 with a cURL, use the following syntax:

    Curl -x

    This syntax will send a request to with the HTTPS protocol and the 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

    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.