If you’re a web server administrator – as I am – every now and then, someone yells at you “The site is down, fix it!”.
A tool you should always keep handy is CURL. It’s a command-line web client (multi-platform – I use it on Win2K), that allows you to see the conversation between a web server and a client (like e.g. your browser).
Let’s say if you check out a page like this:
curl -I http://someserver.com/whatever, you could get
curl: (6) Couldn't resolve host someserver.com'
can you CURL www.google.com? => you’re using a wrong domain name (DNS record does not exist)
you can’t CURL anything => your DNS settings are wrong, or your DNS server does not work as expected
curl: (7) Connect failed
there is no web server answering on that port
=> is the server down? does site run on other port? does a restart help?
HTTP/1.1 401 Access Denied [WWW-Authenticate: Basic realm="someserver.com"]
you have to log in to this page – your browser would pop up a username/password screen
HTTP/1.1 403 Access Forbidden
there is no ‘default’ document in the folder you are requesting
=> option 1: there should be a document index.html, default.htm, … in each folder
=> option 2: you want the folder to be browsable, so you have to configure this on the server
HTTP/1.1 404 Object Not Found
the document you ask for does not exist.
=> are you asking for the right document (typo)? on the right server?
HTTP/1.1 500 Server Error
typically only for dynamic pages (asp/php/cgi), where the program code contains an error and there is no HTML result that can be shown.
=> go look into the web server or program logs in order to find the bug.
HTTP/1.1 302 Found [Location: http://someotherserver.com/somepath]
the site is redirecting you to some other URL, which itself might give an error 404/403/connect failed/…
302 codes are not errors, it’s a common way of sending browser to the right location.
(for example: if this 302 redirects you to a wrong port http://someserver.com:88/whatever and nothing responds on that port, in your IE browser it looks like someserver.com is failing, whereas it really is someserver.com:88)
HTTP/1.1 200 OK
This is the ‘normal’ result of asking a web page.
For SSL/HTTPS problems, you better use
curl -Ivk, because it gives you “* Connected to someserver.com port 443 * SSL connection using RC4-MD5 * Server certificate: (certificate content) …” information.
Have CURL installed on all your machines, Linux or Windows. Actually, add unxutils.sourceforge.net to your Windows machine, so you can work with gawk and wget too.
CURL is not the same as a real browser (especially when working with cookies/sessions), but it can help you solve 90% of typical web server problems. If the problem is browser-related, and you want to see the actual conversation between your browser and the web server, use the Ethereal network protocol analyzer.