Proxy setup in curl

curl through Prokso proxies: HTTP with -x and -U, SOCKS5 via socks5h on port 824, http_proxy and NO_PROXY variables, one IP for many commands.

Updated · Prokso editorial team

Markdown, ready to paste into ChatGPT or another AI assistant
Connection details
Host
gw.prokso.com
Port
823 HTTP · 824 SOCKS5 - new IP per request · 10000–20000 sticky session, HTTP(S) and SOCKS5
Username and password
in your dashboard, on the plan page

Your dashboard generates ready-made lines in the format you need: choose the country, IP type and protocol.

Key takeaways
  • Generator format - protocol://username:password@host:port, the line goes after -x unchanged
  • Always write the port (without it curl uses 1080), for SOCKS5 the socks5h:// scheme
  • The correct result - the proxy IP in the api.ipify.org response; an error is explained by the exit code
Proxies in curl: a short video guide · 0:33 · Open the video page
Video transcript

Prokso proxies in curl.

First, get your proxy details from the dashboard: host, port, username and password. They are on the plan page, in the Access block.

In curl, the -x option sets the proxy address, and the -U option (capital U) sets the username and password.

Run the example: the output should show the proxy IP, not yours. On port 823, every run gets a new address.

The full guide with examples is on the Prokso website.

A step-by-step guide to connecting Prokso proxies in curl. It takes a few minutes.

Step 1. Copy the proxy address in the form the -x flag understands

The -x flag in curl takes the proxy address in the form [protocol://]host[:port], and the username and password can be passed separately with -U or written right into the address. The shortest way is the generator format protocol://username:password@host:port: such a line goes after -x unchanged.

Always write the port. According to the curl documentation, if the proxy address has no port, curl uses 1080, and Prokso does not respond on that port. The scheme matters too: an address without a scheme is treated as an HTTP proxy, so SOCKS5 needs socks5h:// or socks5://. If you choose SOCKS5 in the generator, the line starts with socks5://, and for DNS through the proxy you only need to add the letter h.

On port 823 each request gets a new address, on 824 the same but through SOCKS5, and sticky ports 10000-20000 keep one address for 1 to 120 minutes. curl passes the country together with the username, for example username__cr.ua, so there is no separate flag for it. curl decodes the username and password in the address, so write the @ character in a password as %40 and a colon as %3a.

The “Access” block on the plan page: host, ports, username and password for the proxy line
The “Access” block on the plan page: host, ports, username and password for the proxy line

Step 2. HTTP proxy in one line

The -x flag sets the proxy and -U the username and password. Use quotes: if the username carries parameters like USERNAME__cr.ua or a semicolon, the shell will break it without them.

curl -x http://gw.prokso.com:823 -U "USERNAME:PASSWORD" https://api.ipify.org

Step 3. SOCKS5

For SOCKS5 use the socks5h:// scheme and port 824 (a new IP for every request) or a sticky 10000-20000 port, which works with SOCKS5 too. The h means the proxy resolves the site's domain name, not your computer, so DNS lookups don't leave from your IP either.

curl -x socks5h://gw.prokso.com:824 -U "USERNAME:PASSWORD" https://api.ipify.org

Step 4. Environment variables

To avoid typing -x every time, set variables. For HTTP curl only reads lowercase http_proxy; for HTTPS either https_proxy or HTTPS_PROXY works. List addresses that should go direct in NO_PROXY.

export http_proxy="http://USERNAME:PASSWORD@gw.prokso.com:823"
export https_proxy="$http_proxy"
export NO_PROXY="localhost,127.0.0.1"
curl https://api.ipify.org

Step 5. See which address the curl command returned

Each example above calls https://api.ipify.org, and this service replies with one line: the IP the request came from. The terminal should show the proxy address, not yours. Run the same command again: on port 823 the IP will change, on a sticky port it will stay the same until the end of the session duration.

If curl ended with an error instead of an IP, the number in brackets at the start of the message is the exit code. What codes 5, 7, 28, 56 and 97 mean is covered in the "What curl errors mean" section below. To see the whole exchange with the proxy, add -v: lines with > are what curl sent, lines with < are what it received.

A browser does not use these settings, so check the command output in the terminal.

Example run: the output shows the proxy IP, not yours. On port 823 every run gets a new address
Example run: the output shows the proxy IP, not yours. On port 823 every run gets a new address

Useful flags when working through a proxy

  • --max-time 30: an overall time limit. Without it, a hung request hangs forever.
  • --connect-timeout 10: a separate limit for connecting to the proxy.
  • --retry 3 --retry-delay 2: a retry on temporary failures; on port 823 every retry goes out from a new IP.
  • --compressed: request a compressed response, which means less traffic for the same content.
  • -I: headers only. Handy for checking whether a site responds without downloading the page.
  • -s -o /dev/null -w "%{http_code}\n": print only the response code.

Country and session in the username

The proxy parameters are written in the username. The country is USERNAME__cr.de. The easiest way is to build the username you need in the generator in your dashboard and copy it from there. The quotes around the username are required: without them the shell will interpret the special characters in its own way.

# exit IP in Germany, a new address for every request
curl -x http://gw.prokso.com:823 -U "USERNAME__cr.de:PASSWORD" https://prokso.com/ip

# the same IP for a series of commands: a sticky port
curl -x http://gw.prokso.com:10001 -U "USERNAME__cr.de:PASSWORD" https://prokso.com/ip

What curl errors mean

  • (5) Could not resolve proxy. There is a typo in the proxy host name.
  • (7) Failed to connect. The proxy is not reachable on this port: check the port and whether it is blocked on your network.
  • (56) CONNECT tunnel failed, response 407. The username and password are wrong or the plan has run out of traffic.
  • (28) Operation timed out. The response did not arrive in time: increase --max-time or retry the request.
  • (97) or a SOCKS negotiation failure. The scheme does not fit the port: 823 is HTTP only, 824 is SOCKS5 only.

The response codes of the site itself are covered on the proxy error codes page.

If the proxy does not work

FAQ

How do I see that the request really goes through the proxy?

Add -v. According to the curl documentation, in the verbose output lines with &gt; are headers curl sent, and lines with &lt; are headers it received. Which address the request came from is shown by the https://api.ipify.org response itself.

Why does curl ignore uppercase HTTP_PROXY?

It's a deliberate security restriction in curl. For HTTP use only lowercase http_proxy.

How does curl work with a proxy on Windows?

The same way. In PowerShell the name curl may call a built-in command with different parameters, so write curl.exe.

How is socks5 different from socks5h?

With socks5h, the site name is resolved by the proxy rather than by your computer. DNS requests then do not bypass the proxy.

How do I save the response to a file?

Add -o filename. The proxy does not affect this.

Was this guide helpful?

Proxy not working? Check it in 6 steps

Install the Prokso app