USE CODE "NEWUSER10" FOR 10% DISCOUNT

How to use a proxy with cURL, Python and Node.js

· 2 min read · By AuraProxies team

Copy-paste examples for sending requests through an HTTP or SOCKS5 proxy with username and password, plus how to pick the exit country and keep a sticky IP.

Every proxy plan gives you the same four things: a host, a port, a username and a password. This post shows how to plug them into the tools most scrapers use. Replace USERNAME and PASSWORD with the values from your dashboard.

cURL

The quickest way to check a proxy works:

curl -x http://USERNAME-country-us:[email protected]:13337 https://api.ipify.org

The reply is the IP address the website sees. Run it twice: with a rotating session you get a different IP each time.

For SOCKS5, change the scheme. The same port carries both protocols:

curl -x socks5h://USERNAME-country-us:[email protected]:13337 https://api.ipify.org

socks5h (with the h) lets the proxy resolve the hostname, so your own DNS server never sees which site you're visiting.

Python (requests)

import requests

proxy = "http://USERNAME-country-de:[email protected]:13337"
r = requests.get("https://api.ipify.org", proxies={"http": proxy, "https": proxy}, timeout=30)
print(r.text)

Set a timeout. A residential IP is a real home connection, and now and then one is slow or drops; without a timeout your script can hang forever.

Node.js

Node's built-in fetch doesn't read proxy settings by itself. The undici package (the library behind fetch) adds them:

import { ProxyAgent, fetch } from "undici";

const agent = new ProxyAgent("http://USERNAME-country-gb:[email protected]:13337");
const res = await fetch("https://api.ipify.org", { dispatcher: agent });
console.log(await res.text());

Pick the country and the session

On Residential and Mobile, the location and the session live in the username, so every tool above works the same way:

  • USERNAME-country-us: a new US IP on every request
  • USERNAME-country-us-city-losangeles: narrow it to a city
  • USERNAME-country-us-session-k2j9x0aq-ttl-30: keep one IP for up to 30 minutes

Use a different session id for each account or browser profile you run in parallel. Not sure which to use? Read rotating vs sticky sessions.

Common errors

  • 407 Proxy Authentication Required: the username or password is wrong, or the country code has a typo.
  • Connection timed out: check the port, and that your firewall allows outgoing connections to it.
  • The IP is in the wrong country: check the -country- part of the username; it uses two-letter codes like us, gb, de.

The proxy generator in your dashboard builds these lines for you, ready to copy.

  • tutorial
  • python
  • nodejs

Create a free account

Sign-up is free. Buy proxies from your balance when you need them.