ProxyHealthList

Home / Use cases / curl

How to Use a Proxy with curl

curl speaks HTTP, HTTPS and SOCKS proxies natively. Below are the exact flags for each type, plus a one-liner that grabs a working proxy straight from the free, hourly-verified list.

All proxies (TXT) Build a test command

The flags for each proxy type

Proxy typecurl command
HTTP / HTTPScurl -x http://host:port URL
SOCKS5 (remote DNS)curl --socks5-hostname host:port URL
SOCKS5 (local DNS)curl --socks5 host:port URL
SOCKS4curl --socks4 host:port URL

Always add --max-time 10 so curl gives up quickly on a dead proxy instead of hanging.

Environment variables

export http_proxy="http://1.2.3.4:8080"
export https_proxy="http://1.2.3.4:8080"
curl -I "https://example.com/"        # uses the proxy automatically

Grab a working proxy in one line

Download the list, take the first (fastest) entry, and use it immediately:

proxy="$(curl -sL https://raw.githubusercontent.com/xyzs996/free-proxy-health-list/main/proxies/protocols/http/data.txt | head -n 1)"
curl -x "http://$proxy" -I "https://example.com/" --max-time 10

Loop until one works

curl -sL https://raw.githubusercontent.com/xyzs996/free-proxy-health-list/main/proxies/protocols/http/data.txt \
| while read -r proxy; do
    if curl -x "http://$proxy" -s -o /dev/null -I "https://example.com/" --max-time 8; then
      echo "working: $proxy"; break
    fi
  done

Frequently asked questions

--socks5 or --socks5-hostname?

--socks5 resolves DNS locally; --socks5-hostname resolves through the proxy. Prefer --socks5-hostname to avoid DNS leaks.

curl hangs on a proxy — what do I do?

Add --max-time (and optionally --connect-timeout). Free proxies die constantly, so time out fast and move to the next entry.

Can I test a proxy without writing a script?

Yes — the test command builder generates a ready-to-run curl command for any proxy and protocol.

Related