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.
Back to Web ServicesBasic Requests 6
curl https://example.comGET request, outputs response body to terminal
curl -X POST https://api.example.comSpecify HTTP method: POST/PUT/DELETE
curl -H "Content-Type: application/json" -H "Authorization: Bearer xxx" https://api.example.comAdd request headers, can stack multiple -H
curl -d '{"k":"v"}' https://api.example.comSend POST body, default Content-Type is application/x-www-form-urlencoded
curl -d @file.json https://api.example.comRead 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.comFull request/response headers and handshake, first choice for debugging
curl -I https://example.comResponse headers only, quick status and cache check
curl -L https://example.comFollow 301/302 redirects, use --max-redirs to limit
curl -w "%{http_code} %{time_total}\n" -o /dev/null -s https://example.comOutput only status code and total time, common for monitoring probes
curl -s https://example.comSilent mode, no progress or errors, pair with -o
curl --resolve example.com:443:1.2.3.4 https://example.comOverride DNS resolution, debug load balancers and certificates
Proxy & Timeout 5
curl -x http://proxy:8080 https://example.comUse HTTP proxy
curl -x socks5h://127.0.0.1:1080 https://example.comUse SOCKS5 proxy, h means DNS goes through proxy too
curl --connect-timeout 5 https://example.comConnection timeout 5s, prevent hanging
curl --max-time 30 https://example.comMax total time 30s including connect and transfer
curl --retry 3 https://example.comAuto-retry 3 times on failure
Auth & Upload 5
curl -u user:pass https://example.comHTTP Basic auth
curl -F "file=@photo.jpg" https://example.com/uploadUpload file as multipart/form-data
curl -F "file=@photo.jpg" -F "name=tom" https://example.com/uploadUpload file with form fields
curl -o photo.jpg https://example.com/photo.jpgSave response to file, for large downloads
curl --cookie "session=abc" https://example.comSend 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.