How to Use Proxies with cURL, Python and Node.js
Once your proxies are active, the dashboard gives you each one as a line of text. This guide shows how to plug those lines into the three tools developers reach for most.
Reading your proxy line
The proxy manager can export lines in several formats. The most common is:
HOST:PORT:USERNAME:PASSWORDHOST — the proxy's IP address (ISP proxies) or the gateway hostname (rotating residential and mobile proxies).
PORT — the port to connect to.
USERNAME / PASSWORD — your proxy credentials. If you've whitelisted your server's IP instead, the line is just
HOST:PORTand no credentials are needed.
Most tools want a URL instead, so the same proxy becomes:
http://USERNAME:PASSWORD@HOST:PORTUse socks5:// instead of http:// to connect over SOCKS5. Throughout this guide, replace the capitalised placeholders with the values from your dashboard.
cURL
-x (or --proxy) sends a request through a proxy:
curl -x http://USERNAME:PASSWORD@HOST:PORT https://api.ipify.orgFor SOCKS5, use socks5h:// so DNS lookups also happen on the proxy side:
curl -x socks5h://USERNAME:PASSWORD@HOST:PORT https://api.ipify.orgThe response is the IP address the website sees. If it matches your proxy rather than your own connection, you're set.
Python (requests)
import requests
proxy = "http://USERNAME:PASSWORD@HOST:PORT"
proxies = {"http": proxy, "https": proxy}
response = requests.get("https://api.ipify.org", proxies=proxies, timeout=30)
print(response.text)For SOCKS5, install the extra dependency with pip install "requests[socks]" and use a socks5h:// URL in the same dictionary.
To spread work across several ISP proxies, keep a list and pick one per request:
import random
import requests
with open("proxies.txt") as f:
lines = [line.strip() for line in f if line.strip()]
def proxy_url(line):
host, port, user, password = line.split(":", 3)
return f"http://{user}:{password}@{host}:{port}"
url = proxy_url(random.choice(lines))
response = requests.get("https://api.ipify.org", proxies={"http": url, "https": url}, timeout=30)
print(response.text)Node.js
Node's built-in fetch doesn't take a proxy option directly. The undici package (the engine behind Node's fetch) provides a ProxyAgent:
import { fetch, ProxyAgent } from "undici";
const dispatcher = new ProxyAgent("http://USERNAME:PASSWORD@HOST:PORT");
const response = await fetch("https://api.ipify.org", { dispatcher });
console.log(await response.text());Using axios? Pass the proxy details in the request config:
import axios from "axios";
const { data } = await axios.get("https://api.ipify.org", {
proxy: {
protocol: "http",
host: "HOST",
port: PORT,
auth: { username: "USERNAME", password: "PASSWORD" },
},
});
console.log(data);Troubleshooting
407 Proxy Authentication Required — the username or password is wrong, or your IP isn't whitelisted. Copy the line again from the dashboard.
Connection refused or timeout — check the port and protocol (HTTP vs SOCKS5), and that your plan is active.
Special characters in the password — URL-encode them (for example
@becomes%40) when building a proxy URL.Your real IP shows up — the tool isn't using the proxy for that request. For HTTPS URLs make sure both
httpandhttpskeys are set (Python) or the agent is passed (Node).
Still stuck? Email support with the command you ran and the error you got.
Next steps
Scraping at scale? See how to set up proxies for web scraping and when to use rotating vs sticky sessions. Don't have proxies yet? Compare plans on the pricing page.
Frequently Asked Questions
HTTP(S) proxies work with almost every scraping library and browser. SOCKS5 carries any TCP traffic, not only web requests, which helps with non-HTTP tools. Both are supported, so use whichever your software prefers.
Request an IP echo service such as https://api.ipify.org through the proxy. It returns the public address your traffic leaves from, which should be the proxy's address.
Yes. Whitelist your server's IP in the proxy manager and connect with just HOST:PORT. It's convenient for servers with a fixed IP; use username and password authentication everywhere else.
- Integrations
- Python
- Node.js
- cURL
- SOCKS5