telnet fails to connect: Connection closed by foreign host

4

3

I try to connect to localhost with telnet:

% telnet localhost 6311

This connection succeed, but when I connect by external IP of my computer, connection fails:

% telnet x.x.x.x 6311
Trying x.x.x.x...
Connected to x.x.x.x
Escape character is '^]'.
Connection closed by foreign host.

What could be wrong?

sunny

Posted 2013-05-05T13:28:26.207

Reputation: 175

Firstly, the site address. Try on SuperUser or ServerFault. – H2CO3 – 2013-05-05T13:29:36.770

I checked :

% sudo telnet x.x.x.x 6311

same problem... – None – 2013-05-05T13:33:21.097

It's not a web server there, it is RServe.. Then I don't have any site address... – None – 2013-05-05T13:36:05.997

Answers

3

The problem was with the service ( that was running on 6311) The servise just was not configured to work with remote access.

It means, telnet was OK :)

sunny

Posted 2013-05-05T13:28:26.207

Reputation: 175

1

Check what IP server is listening to. I am suspecting that your server is listening to localhost or 127.0.0.1. Make it listen to 0.0.0.0 (probably via some conf file).

You can verify it by running

netstat -tapnl | grep 6311

Check if it shows 127.0.0.1:6311 or 0.0.0.0:6311

anishsane

Posted 2013-05-05T13:28:26.207

Reputation: 845

If this answer solves your problem, you can mark this as accepted answer.. :) – anishsane – 2013-05-14T07:00:24.583