spyderproxy

How to Use cURL for HEAD Requests (2026)

D

Daniel K.

|
Published date

Fri May 01 2026

Quick verdict: Use curl -I <url> to send a HEAD request and get back only the response headers — no body. It's the right tool for checking file sizes before download, tracing redirect chains, validating Content-Type, or doing fast liveness checks. -I beats -X HEAD in every case because -X HEAD can hang waiting for a body that never comes.

This guide covers what HEAD actually does at the protocol level, the -I vs -X HEAD distinction that trips up a lot of developers, eight copy-paste examples for common tasks, and how to send HEAD requests through a proxy for scraping or geo-targeted checks.

What Is a HEAD Request?

HEAD is one of the nine standard HTTP methods defined in RFC 9110. It's identical to GET except the server returns only the response headers — not the body. The same caching, redirects, and authentication rules apply.

Two practical implications:

  • HEAD is much faster than GET when you only need metadata (Content-Length, Content-Type, Last-Modified, ETag).
  • HEAD doesn't waste bandwidth — useful when checking 10,000 URLs daily for changes.

curl -I vs curl -X HEAD

Both look like they do the same thing. They don't.

Flag What it does Pitfalls
-I (uppercase i)Sends HEAD, configures cURL to expect headers only. Shorthand for --head.None — this is the canonical form.
-X HEADOverrides the request method to HEAD but cURL still expects a body.Can hang waiting for a body that doesn't come back. Use only when combining with other options that conflict with -I.

Rule of thumb: always use -I for HEAD. Reserve -X HEAD for the rare case where you need to override an explicit GET set by another flag.

8 Working Examples

1. Basic HEAD request

curl -I https://example.com

HTTP/2 200
content-type: text/html; charset=UTF-8
content-length: 1256
last-modified: Mon, 13 Apr 2026 09:00:34 GMT
cache-control: max-age=300
server: ECS

2. Follow redirects, show every hop

curl -ILs https://bit.ly/example
# -L follows redirects
# -s silences progress
# -I prints headers

3. Check file size before downloading

curl -ILs https://releases.ubuntu.com/24.04/ubuntu-24.04-server-amd64.iso   | grep -i content-length
content-length: 2516582400

That's 2.5 GB — useful to know before kicking off a `wget -c` (see our curl vs wget guide for the full comparison).

4. Just the HTTP status code

curl -Is https://example.com -o /dev/null -w '%{http_code}
'
200

Drops everything except the status code — perfect for shell scripts.

5. HEAD through a proxy with authentication

curl -I   -x http://USER:[email protected]:8080   https://example.com

Use a static residential proxy when you need consistent geo-targeting for the HEAD probe (e.g., checking how a CDN serves different regions).

6. Check Content-Type without downloading

curl -ILs https://example.com/file | grep -i content-type
content-type: application/pdf

7. Validate a long redirect chain

curl -ILs --max-redirs 10 https://t.co/short   | grep -E '^HTTP|^location' | head -20

8. HEAD with custom headers

curl -I   -H 'User-Agent: Mozilla/5.0'   -H 'Accept-Language: en-US'   https://example.com

HEAD Through a Proxy

For scraping workflows, you often want to use HEAD to filter URLs before doing full GETs — e.g., skip pages that redirect to a 404 or have wrong Content-Type. Through a proxy, all the same flags apply:

curl -I   -x http://USER:[email protected]:8080   -H 'User-Agent: ScrapeBot/1.0'   --max-time 10   https://target-site.com/listing/12345

For high-volume HEAD scanning across thousands of URLs, use a rotating residential proxy so each request appears to come from a different IP — most servers don't rate-limit HEAD as aggressively as GET, but it still helps. Verify your proxy is routing properly first with our proxy checker.

HEAD vs GET vs OPTIONS

Method Returns body? Use when
HEADNoLiveness check, file-size lookup, redirect tracing, Content-Type discovery
GETYesFetch content. Required when HEAD is not supported (rare, but happens)
OPTIONSNoCORS preflight, discovering allowed methods on an endpoint

Common Errors

  • 405 Method Not Allowed: The server doesn't accept HEAD on this URL. Fall back to curl -s -o /dev/null -w '%{http_code} %{size_download}' <url> to send GET but discard the body.
  • Hanging on -X HEAD: Switch to -I. The override flag confuses cURL's body-handling logic.
  • Empty headers in script output: Add -s to silence progress and --fail if you only want successful responses.
  • Headers in wrong order: Server-controlled. cURL prints them in the order received. Use -D - to dump headers separately if scripting.