Search This Blog

Wednesday, June 23, 2010

How to check a website from the commandline

Sometimes it's useful to check a website connectivity using only command line. I.e. when trying a website from remote host, or when you set up a new box you are going to put behind a loadbalancer.

If you need HTTP connection, telnet will be enough:

> telnet 10.10.10.10 80

GET /index.html HTTP/1.1
host: important.site.com

In the case of HTTPS you need openssl:

> openssl s_client  -connect 10.10.10.10:443 -prexit

GET /index.html HTTP/1.1
host: important.site.com

This is entry for my extend my 'external memory', but you might find it useful.

3 comments:

GDR! said...

Telnet happens to insert some extra control characters, I have found netcat nc host 80 more reliable

Wawrzek said...

@GDR! I know that I can check in documentation, but I have quick question.

Can you, using nc of course, ask server a10.kota.pl to show you the index.html page of the ala.ma.kota.pl website? (I.e. to make a test before putting the a10 server behind loadbalancer)

arab said...

You can use curl for that:

curl http://somesite
or
curl -I http://somesite (to just print the header response information)