Home › Residential proxies › ISP Proxies

How to Use a Proxy with cURL

HTTP, HTTPS & SOCKS5 · auth, env vars, .curlrc · error playbook · updated 6 November 2026
Tutorials
Home › Tutorials › How to Use a Proxy with cURL

The quickest way to send a request through a proxy in cURL is the -x flag (long form --proxy):

curl -x http://USER:PASS@GATEWAY:PORT https://api.ipify.org

api.ipify.org echoes the exit IP — if the output matches your proxy's IP instead of your own, the tunnel works.

Proxy URL syntax

cURL accepts a full URL as the proxy value. The scheme decides the protocol used between you and the proxy:

http://user:pass@host:port      # HTTP proxy (most common)
https://user:pass@host:port     # proxy itself reached over TLS
socks5://user:pass@host:port    # SOCKS5, hostname resolved by proxy
socks5h://user:pass@host:port   # SOCKS5, hostname resolved AT proxy
Prefer socks5h:// over socks5:// for scraping: the h makes DNS resolution happen on the proxy side, so DNS leaks and geo-mismatched CDN routes disappear.

HTTPS targets through an HTTP proxy

For https:// URLs cURL issues an HTTP CONNECT request to the proxy, then upgrades the tunnel to TLS. The proxy never sees the plaintext — that is why plain HTTP proxies are fine for HTTPS targets:

curl -x http://USER:PASS@GATEWAY:PORT https://target-site.com -I

If you get 407 Proxy Authentication Required, the credentials are wrong or missing; if you get CONNECT tunnel failed, the proxy does not allow that host or port.

Environment variables

cURL (and most Unix tools) honor lowercase environment variables. Set them once per shell:

export http_proxy="http://USER:PASS@GATEWAY:PORT"
export https_proxy="http://USER:PASS@GATEWAY:PORT"
export all_proxy="socks5h://USER:PASS@GATEWAY:PORT"
export no_proxy="localhost,127.0.0.1,.internal.example.com"

no_proxy excludes hosts that must bypass the tunnel — always include your own infrastructure and health-check endpoints.

Per-project config with .curlrc

Environment variables leak between projects. A scoped config file does not:

# ~/projects/shop-monitor/.curlrc
proxy = "http://USER:PASS@GATEWAY:PORT"
noproxy = "localhost,127.0.0.1"
curl -K ~/projects/shop-monitor/.curlrc https://target-site.com

Verifying what the target sees

Exit IP is only half of the story. Also check the geo and ASN the target infers:

curl -x http://USER:PASS@GATEWAY:PORT https://api.ipify.org
curl -x http://USER:PASS@GATEWAY:PORT "https://ipinfo.io/json" | head -20

Rotation

With a rotating gateway you do not rotate in cURL — the provider rotates exit IPs for you. To pin a session (same IP across several requests), most providers accept a session token in the username; with cURL you simply reuse the same credentials:

for i in 1 2 3; do
  curl -s -x http://USER-SESSION-abc123:PASS@GATEWAY:PORT https://api.ipify.org; echo
done

Common errors cheat sheet

ErrorMeaningFix
407 Proxy Authentication RequiredWrong or missing credentialsCheck user/pass, URL-encode special characters (%40 for @)
CONNECT tunnel failedProxy refuses the target host/portConfirm the plan allows HTTPS and that port 443 is not restricted
56 Recv failureConnection reset mid-transferRetry with a new session IP; reduce concurrency
TLS errors only on proxyProxy or middlebox intercepting TLSUse socks5h:// or a TLS-capable proxy entry

FAQ

Does -x work for HTTPS URLs?

Yes. For https:// targets cURL opens an HTTP CONNECT tunnel through the proxy and upgrades it to TLS, so the proxy never sees plaintext. A plain http:// proxy entry is sufficient for HTTPS targets.

socks5 vs socks5h in curl?

socks5 resolves DNS locally; socks5h resolves DNS on the proxy side. For scraping use socks5h to avoid DNS leaks and geo-mismatched CDN routes.

How do I rotate IPs in curl?

You don't — a rotating gateway rotates exit IPs server-side. To pin one IP across requests, include a session token in the proxy username and reuse the same credentials.

Why 407 Proxy Authentication Required?

The proxy rejected your credentials. Check the user:pass portion of the proxy URL and URL-encode special characters, e.g. @ becomes %40.

Ready to test against a real pool? IPLight's rotating residential proxies start at $1.20/GB (down to $0.72/GB at volume) across 170+ countries — see pricing or the live pool report.

Test on your own target list

Residential from $1.20/GB · static ISP from $2/IP per month (15+ IPs) · no monthly commitment. Create an account, top up a small balance and run your first requests in minutes.

Create account

Frequently asked questions

How much does it cost?

Dynamic residential traffic starts at $1.20/GB on the 100 GB tier ($120), dropping to $0.96/GB at 1,000 GB, $0.72/GB at 5,000 GB and $0.60/GB at 10,000 GB. Static residential IPs are $3/IP/month, or $2/IP/month from 15 IPs. There are no setup fees or monthly platform fees.

Does traffic count both upload and download?

Yes - traffic is metered in both directions and 1 GB = 1,000 MB. The console shows an hourly usage breakdown per sub-account, so you can audit exactly what each job consumed. Disabling images and video in your crawler cuts usage significantly.

Is there a contract or minimum commitment?

No. Top up once and spend the balance across dynamic traffic, static IPs and unlocking. Paid orders keep their unit price even if the public price list changes later.

Which protocols are supported?

HTTP and SOCKS5 endpoints are provided, with username/password or IP-whitelist authentication. AdsPower, BitBrowser, Python, Node, Scrapy, Playwright and Puppeteer all connect directly.

What is the difference between ISP proxies and static residential proxies?

At IPLight they are the same product: real IP addresses registered to consumer internet service providers, dedicated to your account for the whole term. Some providers sell 'ISP proxies' that are actually datacenter ranges announced by an ISP - ours are checked as residential before they enter inventory.

Can I keep the same IP for months?

Yes. Choose a 30, 90 or 180-day term and the same IP stays assigned to your account for the full term, which is what makes ISP proxies suitable for account management and long-lived logins.

Popular proxy locations: All locations · USA · UK · Germany · Japan · Indonesia · Brazil · India · Russia
Popular products: Residential proxies · ISP proxies · SERP proxies · Static residential · Pricing
IPLight live residential pool: 215,000+ online IPs across 170+ countries & regions · dynamic residential from $1.20/GB · pool sizes measured in real time · updated 2026-11