System Administration

Check HTTP with telnet

HTTPS may become the standard quickly, but HTTP is still the base, and understanding how to verify an HTTP server without a web browser can be very useful. A lot of situations simply don’t allow you to install a web browser or gives only a blank page.

As HTTP is a plain-text protocol you can simulate a connection with telnet on the command line. So let connect to a fresh Linux machine with Apache running and see what happens. After connecting you type in “GET /index.html HTTP/1.1” to tell web server which files you want to get and in this case the file in /index.html. The second line tells the web server for which website you make the request which is in the example. And finally, you give an additional entry to tell your request is complete and can be processed after which you get the response.

$ telnet 80
Connected to
Escape character is '^]'.
GET /index.html HTTP/1.1

HTTP/1.1 404 Not Found
Date: Sun, 06 Jan 2019 01:27:00 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.3.0
Content-Length: 208
Content-Type: text/html; charset=iso-8859-1

<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL /index.html was not found on this server.</p>
Connection closed by foreign host.

The response in the example tells that the file index.html doesn’t exist on the web server, which is correct for this example. It also gives additional metadata about the server and the form the content is served which can be handy to see if the mime-type matches or the response size is correct.

By Hans Spaans

Unix & security consultant with a passion for Linux, Solaris, PostgreSQL, Perl and network services, but also a strong believer in open and free source, standards and content.