Socks5Proxy

cURL proxy guide: Testing HTTP/SOCKS5 proxies via command line

This guide provides cURL commands for HTTP/SOCKS5 proxy testing, auth, latency checks, and bulk verification scripts.

Why is cURL ideal for proxy testing?

cURL is preinstalled on most servers/dev environments, making it the fastest way to verify proxy functionality. When issues arise in code/browser settings, cURL tests isolate proxy vs. code problems instantly.

The example uses IP 198.51.100.23, HTTP port 8000, SOCKS5 port 1080, username spx_user, and password spx_pass.

How do I connect HTTP proxy?

Add proxy address with -x (or --proxy). Include credentials in the address or separately with -U. For HTTPS, cURL creates a CONNECT tunnel for encrypted requests.

# user and password inside the proxy URL
curl -x http://spx_user:spx_pass@198.51.100.23:8000 https://api.ipify.org

# or with -U
curl -x http://198.51.100.23:8000 -U spx_user:spx_pass https://api.ipify.org

How do I connect SOCKS5 proxies?

--socks5-hostname performs DNS resolution through the proxy, hiding your server's DNS requests and resolving names based on the proxy's country. --socks5 resolves names locally before sending IPs to the proxy. We recommend --socks5-hostname in most cases.

Using socks5h:// format with -x yields identical results.

# DNS is resolved by the proxy
curl --socks5-hostname 198.51.100.23:1080 --proxy-user spx_user:spx_pass https://api.ipify.org

# same thing with a proxy URL
curl -x socks5h://spx_user:spx_pass@198.51.100.23:1080 https://api.ipify.org

How to monitor response times and statuses?

Use -w to display connection time, time to first byte, total time, and response code in one line. Useful for comparing proxy speeds across countries or diagnosing slow sites vs. slow proxies.

Discard body with -o /dev/null and silence progress with -s for clean output.

curl -s -o /dev/null \
  -x http://spx_user:spx_pass@198.51.100.23:8000 \
  -w "code=%{http_code} connect=%{time_connect}s ttfb=%{time_starttransfer}s total=%{time_total}s\n" \
  https://example.com/

How to check the entire list at once?

Run cURL for each line of an API-fetched list to check all proxies at once. This script tests ip:port:user:pass entries, printing response IPs and latency with timeout to skip unresponsive proxies.

#!/bin/sh
KEY="YOUR_API_KEY"
curl -s -H "Authorization: Bearer $KEY" \
  "https://socks5proxy.io/api/v1/proxies/download?format=ip:port:user:pass&protocol=http" > proxies.txt

while IFS=: read -r ip port user pass; do
  out=$(curl -s -m 15 -x "http://$user:$pass@$ip:$port" -w " %{time_total}s" https://api.ipify.org)
  echo "$ip:$port $out"
done < proxies.txt

Can I call the API with cURL?

Yes. Check balance, active plans, and proxy lists with one Authorization: Bearer header. Filter JSON responses with tools like jq.

curl -H "Authorization: Bearer YOUR_API_KEY" https://socks5proxy.io/api/v1/account
curl -H "Authorization: Bearer YOUR_API_KEY" "https://socks5proxy.io/api/v1/proxies?country=us&protocol=socks5"

Can proxies be configured via environment variables?

Yes. cURL and CLI tools read http_proxy, https_proxy, and all_proxy env vars. Set these once in your shell to apply to cURL, wget, pip, etc. For SOCKS5, use socks5h:// in all_proxy.

List no_proxy addresses (comma-separated) to bypass the proxy for internal servers/localhost.

export https_proxy="http://spx_user:spx_pass@198.51.100.23:8000"
export http_proxy="$https_proxy"
export no_proxy="localhost,127.0.0.1"
curl https://api.ipify.org

# SOCKS5 for every tool that reads all_proxy
export all_proxy="socks5h://spx_user:spx_pass@198.51.100.23:1080"

How to compare HTTP proxy vs SOCKS5 results?

Compare response IPs/times when requesting same address via both ports of an IP to see which method performs better in your environment. Most are similar, but differences may appear with distant servers or slow DNS.

Response IPs should match for both protocols. If different, check for mixed ports in your list.

for p in "http://spx_user:spx_pass@198.51.100.23:8000" "socks5h://spx_user:spx_pass@198.51.100.23:1080"; do
  curl -s -m 15 -x "$p" -w "  %{time_total}s\n" https://api.ipify.org
done

How does the server verify IPs for IP authorization?

For IP authorization, register your server's public IPv4 (found via proxy-less `curl -4 https://api.ipify.org`). Whitelisting this IP in your dashboard allows password-free connections from that server.

curl -4 -s https://api.ipify.org

Can proxies view content on HTTPS sites?

For HTTPS via HTTP proxy: cURL first establishes a CONNECT tunnel to target server, then creates encrypted connection within it. Proxy only knows connection target - traffic remains encrypted. Use -v flag to observe CONNECT and encryption steps.

Same for SOCKS5. The proxy relays connections while encryption happens between cURL and the target server. Avoid -k (insecure) flag - the target server's certificate is still verified through the proxy.

With --socks5-hostname, the proxy resolves domain names too, leaving no DNS request traces on your server.

curl -v -o /dev/null -x http://spx_user:spx_pass@198.51.100.23:8000 https://example.com/ 2>&1 | grep -E "CONNECT|HTTP/|SSL connection"

How to read cURL error messages?

Received HTTP code 407 from proxy after CONNECT indicates authentication failure. Check your username and password or the server IP registered for IP authorization. If your password contains @ or :, do not include it in the address; use -U or --proxy-user instead.

Failed to connect or Connection timed out suggests port mismatch or server firewall blocking outbound connections. Use HTTP port for HTTP, SOCKS5 port for SOCKS5, verify outbound ports are open. The -v flag shows connection steps for debugging.

cURL proxy usage: -x and SOCKS5 connection testing | Socks5Proxy