Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to send HTTP HEAD request using wget, is it possible?

share|improve this question
up vote 41 down vote accepted

It's not wget, but you can do that quite easily by using curl.

curl -I

Produces this output:

HTTP/1.1 301 Moved Permanently                        
Content-Length: 144                       
Content-Type: text/html; charset=UTF-8     
Date: Sat, 09 Oct 2010 19:11:50 GMT
share|improve this answer
This is exactly what I want. – Xiè Jìléi Oct 11 '10 at 15:23
-I is equivalent to --head. – Nicolas Marchildon Dec 10 '15 at 20:48


wget -S --spider

You can also pass -O /dev/null to prevent wget from writing HTTP response to a file.

share|improve this answer
-S will show headers, but it executes a GET, not a HEAD. In other words, it will fetch the entire URL. – Dan Dascalescu Feb 28 '14 at 23:21
wget -S --spider http://localhost log created in apache server is - - [04/Mar/2014:15:36:32 +0100] "HEAD / HTTP/1.1" 200 314 "-" "Wget/1.13.4 (linux-gnu)" – Casual Coder Mar 4 '14 at 14:38

No need for curl.

With wget adding --spider implies that you want to send a HEAD request (as opposed to GET or POST).

This is a great minimalistic way of checking if an URL responds or not. You can for example use this in scripted checks and the HEAD operation will make sure you do not put any load on neither the network nor the target webserver.

Bonus info: If wget gets a HTTP error 500 from the server when it performs the HEAD it will then move on to perform a GET against the same URL. I don't know the reasoning for this design. This is the reason why you may see both a HEAD and a GET request being performed against the server. If nothing is wrong then only a HEAD request is performed. You can disable this functionality with the --tries option to limit wget to only 1 attempt.

All in all I recommend this for testing if an URL is responding:

# This works in Bash and derivatives
wget_output=$(wget --spider --tries 1 $URL  2>&1)

if [ $wget_exit_code -ne 0 ]; then
    # Something went wrong
    echo "$URL is not responding"
    echo "Output from wget: "
    echo "$wget_output"
    echo "Check succeeded: $URL is responding"
share|improve this answer

'wget -S' gets file ( Content-Length: 2316, Length: 2316 (2.3K) [text/plain], Saving to: `index.html') 'wget --spider' gets header (Spider mode enabled. Check if remote file exists., Length: unspecified [text/plain] Remote file exists.)

share|improve this answer

Though not wget, many perl installs with lwp module will have a HEAD command installed.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .