← Docs / Proxies
Datacenter proxies with cURL
cURL is the quickest way to check a proxy works. This page uses the datacenter tier: a US datacenter IP that changes for every new connection.
What you need
Your proxy API key, from the Proxies page in the portal. Put it in an environment variable so it stays out of your shell history:
export PB_PROXY_KEY="YOUR_KEY"
Three ways to pass the proxy
All three do the same thing. Pick whichever fits your script.
# 1. Credentials in the proxy URL
curl -x "http://$PB_PROXY_KEY:[email protected]:3128" https://api.ipify.org
# 2. Credentials as a separate flag
curl -x http://proxy.privatebyte.com:3128 -U "$PB_PROXY_KEY:datacenter" https://api.ipify.org
# 3. Environment variable, picked up by cURL and many other tools
export HTTPS_PROXY="http://$PB_PROXY_KEY:[email protected]:3128"
curl https://api.ipify.org
Each prints a US datacenter address, for example 203.0.113.7.
See the rotation
Every cURL command opens its own connection, so every run gets a new IP:
for i in 1 2 3; do
curl -s -x "http://$PB_PROXY_KEY:[email protected]:3128" https://api.ipify.org; echo
done
One cURL command with several URLs reuses a single connection, so it keeps one IP for all of them. Run separate commands when you want a new address for each.
Use SOCKS5
curl --socks5-hostname "$PB_PROXY_KEY:[email protected]:1080" https://api.ipify.org
--socks5-hostname lets the proxy resolve the hostname. Plain --socks5 resolves it on your machine first.
Errors
| What you see | What it means |
|---|---|
407 Proxy Authentication Required |
The API key is wrong or missing. |
400 with Unknown tier "datacentre" |
The tier word is a close misspelling of a real tier. Fix the spelling. A password that is not close to any tier, such as x, uses your account's default tier. |
400 Invalid proxy password settings |
The password asked for something this tier does not do: a country other than US, a session or a TTL. |
A site returns 403 |
The site is refusing datacenter addresses. Try a residential tier such as standard. |
Add -v to see the proxy's answer to the CONNECT request. A 407 or 400 appears there.
Related
Related
Still stuck? Open a ticket — tell us what was missing and the article gets fixed.