NewUnlimited residential proxies: unmetered traffic on a fixed price. From $33.25/day

Command line ยท Integration guide

How to use proxies with cURL

cURL is the quickest way to test a proxy from a terminal. These commands send requests through the Proxonym gateway, pin a sticky IP, target a location and decode gateway errors.

  • 6 steps
  • 12 min setup
  • Copy-paste code

Before you start

  • cURL, included with macOS, most Linux distributions and Windows 10 and later
  • A Proxonym residential or mobile plan
  • Your proxy username and password from the dashboard
Get proxy credentials

Already a customer? Your username and password are in the dashboard.

  1. Check your cURL version

    Any recent build supports HTTP and SOCKS5 proxies. In Windows PowerShell 5.1, type curl.exe instead of curl, because curl on its own is an alias for Invoke-WebRequest there.

    Shell
    curl --version
  2. Send a request through the gateway

    Pass the gateway with -x and your credentials with -U. The response from api.ipify.org is the exit IP the target sees, which should not be your own address.

    Shell
    curl -x http://gw.proxonym.com:8000 -U "USERNAME:PASSWORD" https://api.ipify.org
  3. Target a country, state, city or ASN

    Append parameters to the username with dashes: lowercase ISO country codes, underscores for spaces in place names, and either a state or a city, not both. ipinfo.io shows where the exit IP is located.

    Shell
    # Any IP in Germany
    curl -x http://gw.proxonym.com:8000 -U "USERNAME-country-de:PASSWORD" https://ipinfo.io/json
    
    # New York City, United States
    curl -x http://gw.proxonym.com:8000 -U "USERNAME-country-us-city-new_york:PASSWORD" https://ipinfo.io/json
    
    # The state of California
    curl -x http://gw.proxonym.com:8000 -U "USERNAME-country-us-state-california:PASSWORD" https://ipinfo.io/json
    
    # The Comcast network (ASN 7922)
    curl -x http://gw.proxonym.com:8000 -U "USERNAME-country-us-asn-7922:PASSWORD" https://ipinfo.io/json
  4. Rotate or keep the same IP

    Without a session parameter, every new connection gets a new IP, and each cURL run opens a new connection. Add -session- with an ID of 1 to 32 letters and digits to keep one IP, and -lifetime- to hold it for 1 to 120 minutes (10 by default).

    Shell
    # Rotating: a new IP on every run
    for i in 1 2 3; do
      curl -s -x http://gw.proxonym.com:8000 -U "USERNAME-country-us:PASSWORD" https://api.ipify.org; echo
    done
    
    # Sticky: the same IP for up to 30 minutes
    for i in 1 2 3; do
      curl -s -x http://gw.proxonym.com:8000 -U "USERNAME-country-us-session-a7k2-lifetime-30:PASSWORD" https://api.ipify.org; echo
    done
  5. Switch to SOCKS5

    Use port 1080 with the socks5h:// scheme. The trailing h tells cURL to let the proxy resolve hostnames, so DNS lookups do not leave your machine. Username parameters work exactly as they do on HTTP.

    Shell
    curl -x socks5h://gw.proxonym.com:1080 -U "USERNAME-country-gb:PASSWORD" https://api.ipify.org
  6. Read gateway errors and retry

    For HTTPS targets the gateway answers the CONNECT request, so print %{http_connect} to see its status next to the target status. 407 means wrong credentials, 402 an empty balance or expired plan and 403 a blocked target; 429, 502 and 504 are worth a retry (--retry-all-errors needs cURL 7.71 or newer).

    Shell
    # Show the gateway status and the target status side by side
    curl -s -o /dev/null -w "gateway=%{http_connect} target=%{http_code}\n" \
      -x http://gw.proxonym.com:8000 -U "USERNAME:PASSWORD" https://example.com
    
    # Retry transient failures up to 3 times
    curl --retry 3 --retry-all-errors --max-time 70 \
      -x http://gw.proxonym.com:8000 -U "USERNAME:PASSWORD" https://example.com

Frequently asked questions

Why does cURL report a 407 from the gateway?

The gateway did not accept the credentials. Copy the username and password again from the dashboard, check that parameters are joined with dashes (USERNAME-country-us), and wrap the -U value in quotes so the shell leaves special characters alone. Running the same command with -v shows the CONNECT request and the exact status the gateway returned.

Should I use HTTP or SOCKS5 with cURL?

Both reach the same IP pool and accept the same username parameters. HTTP on port 8000 tunnels HTTPS through CONNECT and works with almost every tool. SOCKS5 on port 1080 suits non-HTTP clients and, with the socks5h:// scheme, keeps DNS resolution on the proxy side. For ordinary web requests, HTTP is the simpler default.

How do I get a new IP on every cURL request?

Leave the session parameter out of the username. The gateway assigns a new IP to each new connection, and every cURL run opens one. If a single command fetches several URLs from the same host, cURL can reuse the connection and therefore the IP, so run one command per request when each request needs a fresh address.

How can I confirm the location of my exit IP?

Send a request to a geolocation endpoint such as https://ipinfo.io/json through the proxy. It returns the IP along with the city, region, country and network that sites are likely to see. Geolocation databases sometimes disagree, so check accuracy at the country or state level first and compare a few lookups before reporting a mismatch.

Ready to plug it in? Get your credentials.

Pick a plan, copy your username and password from the dashboard and run the code above.

  • Pay as you go
  • Instant activation
  • Crypto accepted
  • 24/7 support