How to check TCP Port 80 (http) with telnet
This article describes how to connect to a TCP port 80 on a Web server using telnet.
HTTP Protocol Basics
HTTP[1] is a simple text protocol. So telnet lets you easily test the operation of port 80.
You can test the connection using the following Linux commands:
- Enter
telnet SERVERNAME 80
. Telnet will simply connect to the 80 host port of the specified host name. - If the connection is established via TCP, telnet will respond with the following response:
Connected to SERVERNAME.
andEscape character is '^]'.
- You can retrieve the site from here by using the HTTP protocol. To do so, enter the following two lines with Enter:
GET / HTTP/1.1
HOST: HOSTNAME
- In the server response we get the HTTP status and the web page (such as HTTP / 1.1 200 OK and so on).
Example
In the following example, we will check the http://richardbuz.de page. With the help of the following Linux commands, enter the commands with enter:
telnet richardbuz.de 80
GET / HTTP/1.1
HOST: richardbuz.de
The richardbuz.de server will reply to HTTP and return the HTML code of the page:
[user@cl05]$telnet richardbuz.de 80
Trying 2a00:c760:83:def:aced:ffff:b921:361f...
Connected to richardbuz.de.
Escape character is '^]'.
GET / HTTP/1.1
HOST: richardbuz.de
HTTP/1.1 301 Moved Permanently
Date: Fri, 25 Aug 2017 08:12:53 GMT
Server: Apache
X-Content-Type-Options: nosniff
Location: https://richardbuz.de/
Cache-Control: max-age=1209600
Expires: Fri, 08 Sep 2017 08:12:53 GMT
Content-Length: 230
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://richardbuz.de/">here</a>.</p>
</body></html>
Connection closed by foreign host.
Reference:
- Hypertext Transfer Protocol (en.wikipedia.org)