Command line

How to use a proxy with cURL

cURL is the command-line HTTP client that ships with Linux, macOS and Windows 10 and later. It is the fastest way to prove that a proxy, a username and a token work before you put them into code, because one command shows the exit IP and the full proxy handshake.

cURL takes the proxy with the -x option and the credentials with -U. HTTPS targets are tunnelled through the proxy with CONNECT, so the page stays encrypted end to end. The same flags work in shell scripts, cron jobs and CI pipelines.

Updated 23 November 2026

What you need
Hostgate.firstproxy.shop
HTTP / HTTPS port8000
SOCKS5 port9000
Usernameuser-country-us
PasswordYOUR_TOKEN

cURL supports both ports: HTTP on 8000 with -x, SOCKS5 on 9000 with --socks5-hostname, both with username and password. Your username and token appear on the Proxy setup page of your dashboard after your first order.

Setup

How do I connect cURL to a proxy?

Follow the steps in order. Replace YOUR_TOKEN with the token from your dashboard and change the country, city or session in the username to suit the job.

  1. Check that cURL is installed

    Run curl --version. Any release from the last few years supports everything on this page. On Windows, call curl.exe instead of curl in Windows PowerShell 5.1, where curl is an alias for Invoke-WebRequest and does not accept these flags.

    curl --version
  2. Send a request through the HTTP proxy

    Pass the gateway with -x and your username and token with -U. Keeping the credentials in -U avoids URL encoding problems if your token ever contains characters such as @ or :.

    curl -x http://gate.firstproxy.shop:8000 \
      -U "user-country-us:YOUR_TOKEN" \
      https://ipinfo.io/json
  3. Pick a country and a city

    Targeting lives in the username. Change country-us to any two-letter code, and add -city- with the city name in lowercase, spaces replaced by hyphens.

    curl -x http://gate.firstproxy.shop:8000 -U "user-country-de:YOUR_TOKEN" https://ipinfo.io/json
  4. Keep one IP with a sticky session

    Add -session- with a name you choose and -ttl- with the length in minutes. Every command that uses the same session name leaves from the same IP until the ttl ends. The loop below should print one IP three times.

    for i in 1 2 3; do
      curl -s -x http://gate.firstproxy.shop:8000 \
        -U "user-country-us-session-job42-ttl-10m:YOUR_TOKEN" \
        https://ipinfo.io/ip
      echo
    done

    Use a new session name whenever you want a new IP. Without a session part, every new connection gets a fresh IP.

  5. Use SOCKS5 with remote DNS

    Switch to port 9000 and use --socks5-hostname, which sends the hostname to the proxy so DNS is resolved at the exit, not on your machine. The plain --socks5 flag resolves locally and can reveal which sites you look up.

    curl --socks5-hostname gate.firstproxy.shop:9000 \
      --proxy-user "user-country-gb:YOUR_TOKEN" \
      https://ipinfo.io/json
  6. Set the proxy once with environment variables

    cURL reads http_proxy (lowercase only) and https_proxy or HTTPS_PROXY. Many other command-line tools such as wget and pip read the same variables, so this proxies a whole shell session. Use NO_PROXY for hosts that should go direct.

    export http_proxy="http://user-country-us:YOUR_TOKEN@gate.firstproxy.shop:8000"
    export https_proxy="$http_proxy"
    export NO_PROXY="localhost,127.0.0.1"
    
    curl https://ipinfo.io/json
Test

How do I check that the proxy works?

Request ipinfo.io/json through the proxy. The response shows the exit IP, city and country, so you can confirm the targeting in the username was applied. Add -v to see the CONNECT request and the proxy reply if something fails.

A working proxy returns a response like the one shown, trimmed to the main fields. The IP belongs to the exit, the city and country follow your username, and the time zone is where that IP is located, here United States.

curl -v -x http://gate.firstproxy.shop:8000 \
  -U "user-country-us-city-new-york:YOUR_TOKEN" \
  https://ipinfo.io/json
ipinfo.io/json response
{
  "ip": "203.0.113.24",
  "city": "New York",
  "country": "US",
  "timezone": "America/New_York"
}

203.0.113.24 is a documentation address. Your result shows a real exit IP.

Targeting

How do I set country, city and session in the username?

All targeting is written into the username, so cURL needs no extra settings to change location. Parts are joined with hyphens in this order after your proxy user. The password is always your token.

Proxy username parts
PartFormatExampleRule
Country-country-{cc}-country-usRequired. Two-letter country code in lowercase. 64 countries are available.
City-city-{city}-city-new-yorkOptional. City name in lowercase, spaces become hyphens. 172 cities are available.
Session-session-{id}-session-a1b2c3Optional. Any letters and digits you choose. The same id keeps the same IP, a new id gets a new IP.
Session length-ttl-{minutes}m-ttl-30mUsed with a session. Residential 1 to 120 minutes, mobile 1 to 60, long-acting ISP up to 720 (12 hours).
Full usernameuser-country-us-city-new-york-session-a1b2c3-ttl-30m

Find country codes and city values on the proxy locations page.

Troubleshooting

cURL proxy errors and fixes

The problems people run into most often with cURL, with the message you are likely to see and how to solve it.

curl: (56) CONNECT tunnel failed, response 407

The gateway rejected the credentials. Copy the token again from the dashboard, check there is no space around the colon in -U, and make sure the username starts with your proxy user. If you put credentials in the URL, percent-encode special characters or move them to -U.

Operation timed out

Set limits so a slow exit does not hang a script: --connect-timeout 10 --max-time 30. Add --retry 3 for scheduled jobs. A rare city with few available IPs can be slower to connect than a country-only target.

PowerShell says a parameter cannot be found

Windows PowerShell 5.1 maps curl to Invoke-WebRequest. Type curl.exe, and use a backtick for line continuation instead of a backslash. In cmd.exe the continuation character is ^.

The IP changes inside a sticky session

Check the session name is identical in every command and the ttl has not run out. A ttl above the limit for your product is capped: 120 minutes on residential, 60 on mobile and 720 on long-acting ISP.

curl: (60) SSL certificate problem

This comes from the target site or a local antivirus that inspects TLS, not from the proxy, because HTTPS is tunnelled end to end. Update your CA bundle or test without the inspecting software. Avoid -k in production.

FAQ

cURL proxy questions

Short answers to what people ask most about using a proxy with cURL.

How do I use a proxy with cURL?

Run curl -x http://gate.firstproxy.shop:8000 -U "your-username:YOUR_TOKEN" followed by the URL. The -x option sets the proxy and -U sets the proxy username and password. HTTPS targets are tunnelled automatically.

What is the difference between --socks5 and --socks5-hostname?

With --socks5 cURL resolves the hostname on your machine and sends an IP to the proxy. With --socks5-hostname the proxy resolves it, which keeps DNS lookups at the exit location and avoids DNS leaks. The socks5h:// scheme in -x does the same.

Why does curl ignore my HTTP_PROXY variable?

For plain HTTP targets cURL only reads the lowercase http_proxy variable, for security reasons. For HTTPS targets it reads https_proxy or HTTPS_PROXY. Set the lowercase names to be safe.

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

Leave the session part out of the username. Each new connection then receives a different IP. To keep one IP across commands, add a session name and a ttl, for example -session-job42-ttl-10m.

Get your token and run the first cURL request

Create an account, top up from $40 with crypto, and copy the gateway, username and token from the dashboard.