Learn how to use curl with proxies in this step-by-step guide.
cURL is a tool that helps you move data around online. Whether you're a developer, collecting data, or working with an API, cURL is often the best choice for command-line data transfers. Adding a proxy to cURL makes it even more powerful—giving you better privacy, security, and allowing you to access content from anywhere in the world.
In this guide, we'll show you step-by-step how to use cURL with a proxy, keeping things simple and easy to follow.
Proxies act like middlemen for your internet connection—they send your requests through another server, which hides your real IP address. With proxies, you can access content blocked in your area, browse privately, or collect data without easily getting blocked. Static proxies, like the ones we offer at Stat Proxies, use the same IP address for all your requests, making sure your connection is stable.
First, you need to make sure you have cURL installed on your system.
macOS: It comes pre-installed! Just open the Terminal and check the version:
curl --version
Windows: Many recent versions include it by default. Open Command Prompt to check:
curl --version
Linux: Most Linux distributions come with cURL, but if you need to install it.
sudo apt-get install curl
Now let's make cURL work with proxies. To send your requests through a proxy, use the -x
option:
curl -x [protocol://][username:password@]proxyhost:port [URL]
Here’s what each part means:
Imagine you have a proxy from Stat Proxies with these details:
To make a request through this proxy:
curl -x http://myuser:mypass@212.116.248.54:3128 https://example.com
This command will send your request through our proxy server, keeping your identity hidden.
If you use the proxy often, you can set it as an environment variable so you don’t have to type the proxy details every time.
Linux/macOS:
export http_proxy="http://myuser:mypass@212.116.248.54:3128"
export https_proxy="http://myuser:mypass@212.116.248.54:3128"
Windows:
set http_proxy=http://myuser:mypass@212.116.248.54:3128
set https_proxy=http://myuser:mypass@212.116.248.54:3128
Now, every time you use cURL, it will automatically use the proxy.