curl Cheatsheet - curl HTTP Debugging Command Reference

Essential curl commands organized by Basic Requests, Debugging, Proxy & Timeout, and Auth & Upload. Reference directly when debugging APIs or verifying packets.

Web Services·22 commands·Last updated 2026-07-21
Back to Web Services

Basic Requests 6

curl https://example.com
GET request, outputs response body to terminal
curl -X POST https://api.example.com
Specify HTTP method: POST/PUT/DELETE
curl -H "Content-Type: application/json" -H "Authorization: Bearer xxx" https://api.example.com
Add request headers, can stack multiple -H
curl -d '{"k":"v"}' https://api.example.com
Send POST body, default Content-Type is application/x-www-form-urlencoded
curl -d @file.json https://api.example.com
Read body content from file
curl -G https://api.example.com --data-urlencode "q=hello world"
Append params to URL query string with URL encoding

Debugging & Details 6

curl -v https://example.com
Full request/response headers and handshake, first choice for debugging
curl -I https://example.com
Response headers only, quick status and cache check
curl -L https://example.com
Follow 301/302 redirects, use --max-redirs to limit
curl -w "%{http_code} %{time_total}\n" -o /dev/null -s https://example.com
Output only status code and total time, common for monitoring probes
curl -s https://example.com
Silent mode, no progress or errors, pair with -o
curl --resolve example.com:443:1.2.3.4 https://example.com
Override DNS resolution, debug load balancers and certificates

Proxy & Timeout 5

curl -x http://proxy:8080 https://example.com
Use HTTP proxy
curl -x socks5h://127.0.0.1:1080 https://example.com
Use SOCKS5 proxy, h means DNS goes through proxy too
curl --connect-timeout 5 https://example.com
Connection timeout 5s, prevent hanging
curl --max-time 30 https://example.com
Max total time 30s including connect and transfer
curl --retry 3 https://example.com
Auto-retry 3 times on failure

Auth & Upload 5

curl -u user:pass https://example.com
HTTP Basic auth
curl -F "file=@photo.jpg" https://example.com/upload
Upload file as multipart/form-data
curl -F "file=@photo.jpg" -F "name=tom" https://example.com/upload
Upload file with form fields
curl -o photo.jpg https://example.com/photo.jpg
Save response to file, for large downloads
curl --cookie "session=abc" https://example.com
Send cookies, -c writes -b reads cookie file

💡 Tips

  • When sending JSON with -d, manually add -H "Content-Type: application/json" or the server may fail to parse.
  • For HTTPS certificate issues, use -v to see the handshake; skip verification temporarily with -k (never in production).
  • -w time_total is in seconds. Monitoring scripts should pair with --max-time to prevent hanging.