Is there a shell command to see the headers of a HTTP request?

For example, I would like to know what the headers retrieved from www.example.com/test.php are

How can I do this?


6 Answers 6


In order to retrieve only the header, give this a try:

curl -I http://www.example.com/test.php

From the man page:

(HTTP/FTP/FILE) Fetch the HTTP-header only! HTTP-servers feature the command HEAD which this uses to get nothing but the header of a document. When used on a FTP or FILE file, curl displays the file size and last modification time only.

  • Also, -D <file> will save the headers to a file.
    – coredump
    Mar 20, 2011 at 16:02

Use wget for instance

wget -O - -o /dev/null --save-headers www.example.com/test.php
  • yes, but i don't want to save the page on my pc.....i only want to see the headers
    – Damiano
    Mar 20, 2011 at 10:22
  • 2
    You won't save it with this command Mar 20, 2011 at 11:01
  • Yup, you're just filling /dev/null :p -O - writes the headers to the stdout ("the console")
    – Lekensteyn
    Mar 20, 2011 at 16:00
  • 1
    Command outputs headers and full page to stdout. (Ubuntu 16.04, wget 1.17.1)
    – Frank N
    Aug 22, 2018 at 8:42

You can do that with curl:

curl -i 'http://example.com/'


HTTP/1.0 302 Found
Location: http://www.iana.org/domains/example/
Server: BigIP
Connection: Keep-Alive
Content-Length: 0

(for some reason, IANA decided to redirect example.com, result: no body)

curls manual page about the -i option:


(HTTP) Include the HTTP-header in the output. The HTTP-header includes things like server-name, date of the document, HTTP-version and more...


Or you can use HEAD http://www.example.com. The result is very similar to that produced by curl -i 'http://example.com/' although it seems to return more headers.

200 OK
Connection: close
Date: Sun, 20 Mar 2011 19:08:58 GMT
Server: Apache/2.2.3 (CentOS)
Content-Length: 2945
Content-Type: text/html; charset=UTF-8
Last-Modified: Wed, 09 Feb 2011 17:13:15 GMT
Client-Date: Sun, 20 Mar 2011 19:09:08 GMT
Client-Response-Num: 1

You can see them with curl.


Use curl --include to include the response-headers in the top of the response-body.

or curl --verbose to see it all including SSL certificate exchanging the handshake (plus other debug information)

if the request itself and neither the response-body are not of you concern, just use curl --head

for example curl --head --no-check-certificate --url "https://example.com".

You can download gnu curl already pre-compiled for the most platforms. curl is quite the useful too, especially if you would like to pipe or redirect the result inside a script.
*for example: https://superuser.com/a/1007898/429721

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.