How to use cURL with proxy? (With proxy authentication)

Curl with Proxy

Do you know how to use Curl with proxy? if not, then the article below has been written for you as the article highlights how to use curl with Python in a easy to understand manner.

Client URL is otherwise known simply as Curl is a command line tool used by developers to send data to and from servers. In layman’s terms, Curl let you talk to a server.  This tool has essential command features to be likened compared to others with a similar line of use case. Programmers hugely appreciate the usage of the curl because when its commands are inputted rightly, it will carry out the most complex task with clarity such as transferring files, sending requests, and even web scraping.

But do you know that you can still hide your IP footprint while using Curl to communicate with web servers? in this article, you will be shown how to route your requests in Curl through proxies. Before that, let’s take a look at why you will need to do so.

Why Use Curl with Proxy

YouTube video

The use of curl with proxy has several advantages knowing the tool can be used to write scripts and perform any complex task that allows authentication of username and password and other security layer supports, as aforesaid above. Some reasons why curl is used with proxy are stated and explained below.

To Test Proxy Strength

To Test Proxy Strength

To use a proxy properly, one has to know the capability, especially if the proxy is sourced publicly, where IP addresses are often shared. Also, even if a proxy is from a paid provider, the legitimacy should speak loudly. Using curl with proxy ascertains its capacity because one uniqueness of curl is to test the strength of proxies to know if they are working before using it over any network.



If you are someone whose major workload deals with online activities, you can tell how annoying CAPTCHA can be. The prompt command requesting you to click through some images is not friendly. When running a command-line tool like curl that can see you through retrieving and transferring data, even though it has secure socket layers that can help encrypt its security, with a proxy, the activities will be more flexible, and more work can be achieved.

Proxies are an important gateway in bypassing internally set programs, a website developer knows the strength of Captcha breaker, and with that, they tend to build a site that cannot easily be bypassed. As such why it is more advisable to use proxies along with curl, so you don’t have to avoid accessing websites with this command.

Web Scraping

Web Scraping

Web scraping, among other internet relevance, is why proxies are used. Merging curl with proxy would seem interesting in this area. Since curl is multipurpose and can even run some commands in sync, using a proxy alongside will allow larger files or data from geolocation to be extracted. Understand that a curl is already built with an internal proxy command.

What you need is to punch in the right syntax. While some command prompt is to be inputted with a single hyphen (-x), some are double (–proxy) quotes. Another thing is that try to be explicit because what you send is what will be run; curl doesn’t correct or reset your commands.

How to Use Curl with Proxy

How to Use Curl with Proxy

Setting up Curl with proxy is unlike the step-by-step how-to approaches you frequently search for. In curl, the how-to get down to the features that make up the tool. You can only install curl into your computer, and to do that, go to or check its source code from GitHub. So, now that you understand the concept of curl as well as its relevance with proxy let’s see how you can use curl with proxy.

Identify your IP Address

curl command

Curl with proxy comes with lots of hidden features. If you know you have a proxy connection set aside, the first how in using a curl with proxy is to check your Internet protocol address, and to do that correctly, run the command line by inputting: curl, and your IP address will display. In addition, several other details like city, region, country, and more will show up.

Check your Proxy Server

The intrinsic distinction of using curl with proxy is that curl has an inbuilt proxy command to test the strength and activeness of any proxy. The check proxy server highlights the syntax you can use to test whether or not the proxy to be used is well functioning by simply entering the proxy server IP address or domain name. The command is:

curl -x [IP address or domain name] : [port] OR curl –proxy [IP address or domain name] : [port], e.g., -x 127 .0.0.1 : 443

Connecting Proxy Server

Connecting Proxy Server

Connecting curl with proxy calls for an understanding of the core attributes that make up a proxy and a curl. In using a proxy, you have to know what IP address stands for, port number, and protocols, while curl deals with syntax, and to use both, you have to know where and how the command line of proxy is written in curl, likewise other command keys.

For example, the syntax can be single, double, needs colon, double slash, quotes, amongst others [-x or –proxy, -b or — cookies, -k or –insecure, – “” : //]. The command determines what you input, and for proxy, it’s –x or –proxy, then the necessary details.

Connect with HTTP/HTTPS Proxies

Curl supports HTTP proxies; that’s its default. One thing to mention is that if you want to use HTTPS, you must create the curl command to avoid using the same details as the default. However, some providers will have to set it via your website of interest.

As such, they will ask you to connect through HTTP while they initiate the settings to HTTPS from their side. To create the curl HTTPS file, enter curl https: /domain – after this, the default will change to HTTPS.

Connect with SOCKS Proxies

Connect with SOCKS Proxies

Unlike other proxy protocols, curl with SOCKS proxies have two lines to it; either you use -x, or you use the –socks command line. Socks proxies come in two versions, socks4 and socks5. These are not just names, as their details and functionalities differ.

Socks5 is preferable because of its distinct advantage. While it supports several authentication methods, TCP, and UDP protocols, socks4 does not have such support. Hence, socks5 is mostly used to curl in terms of the socks proxies. The syntax goes thus:

curl -x socks5:// [IP address] : [port] OR curl –socks5 [IP address] : [port]

Use Environment Variables

Environment variable is another how-to-use case of setting proxy with curl. The difference compared to others explained above is that it works at the operating system level, not only on curl. Environment variables are the part of the OS where a command runs to change the entire system processes. Therefore, when a proxy command is enabled, it sets at the system level and not just on curl. Though, you can be specific when preference goes for curl precisely. For environment variables: The proxy determines the starting of your command, i.e., key=value. e.g.

export https_proxy=“http:// 127 .0.0.1 : 443”

export https_proxy=“http:// 127 .0.0.1 : 443”

If you want to run on only curl

Proxy=http:// 127 .0.0.1 : 443

Note that when running an environment variable and an SSL error pops up, type -k to ignore the error. After appropriate entries, press the “Enter key” and run curl

Proxy Authentication (username and password)

Proxy Authentication

If you are on a paid proxy, it will come with authentication. But for public proxy, you don’t need this, though using public proxies for curl activities is not advisable. To enter username and password, always include the command as curl syntax -U then –proxy-user before proxy details. You are not running this on your terms; the server will prompt it. A double quote may be necessary if your password includes special characters.

Curl -U username: password –proxy http://127 .0.0.1 : 443

Curl -x “https://username:password_127 .0.0.1 : 443”

Saving File Result

Saving a file in curl goes with -o or -O. To save a downloaded file to a local drive under an exact name -o should be used. But, if you want a downloaded file name to be saved under the same URL name -O or –remote file name. Curl -o [filename.txt] OR curl -O [URL]


Q. Will Curl Guide Me if I Input an Incorrect URL or Protocol?

Curl is versatile and powerful to accomplish a tough task, but it doesn’t guide or correct URL or Protocol. If you make a mistake in inputting your details, curl will try to make sense of what you’ve typed in, even if it’s wrong, which means that curl works at garbage-in and garbage-out levels. Thus if you input trash commands, it gives you trash. So be careful to punch every syntax clearly, don’t put a hyphen (-) where you are to put the full colon and vice versa.

Q. Can my PC Run Curl?

It depends on how updated your PC is. Curl is agreeable with Linux, Windows, and macOS. Curl can work on any computer so long as the OS is up to date. For Windows users, it works on Windows 10 and other higher versions and not lower. If you don’t have what is required and want to use curl on your device, you will have to update your windows if that’s what you use, and the same applies to the other two OS as well. After that, download the tool. It’s free and easy to use. Go to

Q. Does Curl Support Proxy?

Yes, curl support proxy through an inbuilt proxy command line parameter -x or –proxy option. The default proxy for curl is HTTP; hence, if you want to use other proxies, you have to specify the command line to be set to default instead of HTTP. Additionally, if you are using a proxy that requires an authentication key of username and password, make sure to input the details accurately and clearly. Aside from that, if your authentication details have special characters, encompass the proxy address with double quotes.

e.g., curl –proxy “https://username:password_127 .0.0.1 : 443”


Proxy usage with curl cut across performing several activities. Interestingly, curl can run commands simultaneously, and most of all, it is easy to install, flexible to use, and versatile irrespective of the command line task. In this article, we have worked you through the basic concept of curl and how it can be used with proxy.

Did you like this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.