Search code examples
node.jslocalhosttelnet

Telnet: localhost on Windows 7 will not connect to localhost


I am running a simple Node.JS server with the code:

require('http').createServer(function (req, res) {
  res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
  res.end('<h1>Hi there world</h1>');
}).listen(3000);

It works as expected. When I type "http://localhost:3000" the header "Hi there world" appears.

When I use telnet however:

telnet localhost 3000

I only get the message:

Connecting To localhost...

Firewall is switched off. Telnet connects to external hosts without any problems.


Solution

  • Well, I'd guess your node.js server is waiting for you to issue a GET request. When it is waiting after the message Connecting to Localhost....

    The telnet client doesn't visually indicate that it is connected. Just write your request and it should get entered.

    Put your GET request in:

    GET / HTTP 1.1