I want to know if it is necessary to have telnet enabled on both sides of machines to get telnet connection.

Here's the issue: I am trying to telnet some public IP on port 80 from a Linux web server (Red Hat).

This public IP has got HTTP (80) enabled on it. I'm not sure if telnet is enabled but the owner says it is.

On my Linux server, HTTP (80) is enabled but not telnet. Instead SSH is enabled.

When I telnet from my Linux server: telnet PublicIP 80 it says:

Trying "PublicIP"...
Connected to "PublicIP" ("PublicIP").
Escape character is '^]'.
Connection closed by foreign host

Do is have to enable telnet on my server for it to work? Because there's no issue at the other end as confirmed by other sources. Public IP:

Please explain how can I make it work. If I have to enable telnet on my Linux server, please share the command and method to do so.

  • as we know telnet port it is not secure so most fw block it,are you sure that there isn't any firewall (on the other machine) which block telnet port. – Nidal May 29 '14 at 20:42
  • 1
    It seems you already did what you wanted to... You telnet'ed to the remote HTTP service and since you didn't type anything it closed the connection. You do not need to enable Telnet Service (Server) on any machine. You are using the telnet client. You can also use curl/wget/nc/whatever to do the same thing. – 0xAF May 29 '14 at 20:46
  • There are highly chances are that there is. But its allowed to anyone. even i can telnet it from my home network on my windows PC. but its from my office i am facing. everything is allowed on our side of firewall from this server. – Money May 29 '14 at 20:47
  • 5
    @Networker the security concern is (in this context) just nonsense. telnet is used as a client to test the reachability of a service - and NO, the telnet port is not involved. – guntbert May 29 '14 at 20:48

You are trying to test connectivity to a remote Web server with telnet? Then, no: you do not need telnet servers. The remote HTTP server is waiting for commands, as indicated by the escape character. When it times out waiting, the connection is closed. So...

telnet <hostname or ip address> 80

Then type some HTTP commands:

GET / HTTP/1.1
host: <fqdn>

Use the FQDN of a host that the remote Web server has been configured to serve. It will return the default document with the HTTP commands above. Please note the accurate comment by 0xAF.

  • 3
    The OP needs to input 1 empty line after his input to be able to retrieve any response. Most HTTP servers will allow HTTP/1.0 communication. If the OP is trying to test the HTTP service only, he could just write "GET / HTTP/1.0" and hit the enter key 2 times. – 0xAF May 29 '14 at 20:52

To answer to your question in the first sentence: Telnet is two things: a server-side application (daemon), and a client-side application.

When a telnet server is running, the computer is listening on TCP port 23 for connections from a telnet client.

A telnet client does not listen on any ports, but rather attempts to connect to TCP port 23 (by default) on a computer. If it connects correctly, the user may be prompted to log in and then has an interactive shell session. Because telnet communicates by default using plain, unencrypted text (including your password!), this is NOT recommended.

However, as Christopher says in his excellent answer, if you are really trying to test an http server using telnet, you can use the telnet program for that, and you do not need a telnet server.

The telnet client program can be used to connect to other TCP ports than the default port 23.

telnet <hostname> <TCP port>

Because http servers usually listen on port 80, you can use the telnet program to connect to port 80, and see what the http server is sending to browsers when they connect:

telnet google.com 80

That will connect, but you must then type the following text, which is just a simple http request (case is important):

GET / HTTP/1.1
host: test.com

Then press enter twice.

You'll then see all the raw html that google serves to browsers. You can use this same concept to test your own http servers.


telnet can be used to test the HTTP protocol but there are tools better suited for the task. I personally recommend curl. It is essentially a command line utility that is able to interact with a wide variety of protocols (HTTP, HTTPS, FTP...). Using curl instead of telnet to test an HTTP server will save you from having to manually type in the HTTP requests and it will provide you with more information overall. Some features you might find useful for your current situation are:

Connect to a host using HTTP and request the default document:

curl <public ip>

Connect to a host using HTTP and view the HTTP headers only:

curl -I <public ip>

Connect to host using HTTP, view the HTTP headers only and follow 3xx redirects:

curl -LI <public ip>

curl literally has dozens of options. I recommend using curl --help for a quick summary and man curl or curl --manual for more detailed info.


If you don't have telnet or curl, you can also use cat and proc dir to connect a port:

cat < /dev/tcp/HOST/PORT

Extracted from this article (in Spanish).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.