How to send HEAD requests with cURL

A HEAD request is the fastest way to check whether a URL answers and what metadata it returns without downloading the response body. That makes it useful for health checks, redirect checks, cache validation, and quick inspection of content type or last-modified data.

In cURL, --head or -I switches the HTTP method to HEAD and prints the response headers to standard output. A correct HEAD response should mirror the headers from a comparable GET request, and it may still include Content-Length even though no body bytes are transferred.

Some applications reject HEAD with 405 Method Not Allowed or return a smaller header set than GET, especially behind gateways or older frameworks. Use --location when redirect hops matter, and use --head instead of --request HEAD so curl performs a real header-only transfer.

Steps to send HEAD requests with cURL:

  1. Send a basic HEAD request with --head to print the status line and response headers without the body.
    $ curl --head --silent https://example.com/
    HTTP/2 200
    date: Wed, 22 Apr 2026 03:33:25 GMT
    content-type: text/html
    server: cloudflare
    last-modified: Sat, 18 Apr 2026 00:49:31 GMT
    allow: GET, HEAD
    accept-ranges: bytes
    ##### snipped #####

    -I is the short form of --head. A HEAD response may still show fields such as Content-Length because those describe the corresponding GET response, not downloaded body bytes.

  2. Add --location when the first URL can redirect before the final resource.
    $ curl --head --silent --location http://curl.se/
    HTTP/1.1 301 Moved Permanently
    Connection: close
    Content-Length: 0
    Location: https://curl.se/
    ##### snipped #####
    
    HTTP/2 200
    server: nginx/1.27.5
    content-type: text/html
    content-length: 11393
    ##### snipped #####

    Each response block stays visible, so the last status line and header set show the final resource that curl reached.

  3. Print only the values a script needs with --output /dev/null and --write-out.
    $ curl --head --silent --output /dev/null --write-out 'status=%{response_code}\nheaders=%{size_header}\nbody=%{size_download}\n' https://httpbin.org/anything
    status=200
    headers=202
    body=0

    body=0 confirms that no response payload bytes were transferred, while headers gives a compact size check for alerting or regression tests.

  4. Treat a 405 Method Not Allowed response as proof that the endpoint rejected HEAD.
    $ curl --head --silent https://httpbin.org/post
    HTTP/2 405
    date: Wed, 22 Apr 2026 03:33:46 GMT
    content-type: text/html
    content-length: 178
    server: gunicorn/19.9.0
    allow: POST, OPTIONS
    ##### snipped #####

    Use a normal GET request only when the application actually expects GET semantics. curl's own documentation warns against replacing --head with --request HEAD, because --request changes only the method token and not the rest of curl's transfer behavior.