Linux – Connection closed by foreign host

iptableslinuxtelnet

When I telnet one port of my server, it give me an error: "Connection closed by foreign host", anyone can tell the reason ? thanks!

Best Answer

Given only the informational message from telnet, most likely, the application that accepted your tcp connection either closed the connection on it's own accord or the application crashed/died.

The reason is that all "Connection closed by foreign host." by itself indicates is that the telnet application is of the opinion that the connection was shut down cleanly and the remote end initiated the shutdown. (And the OS/IP-stack (at least on my linux) will do a tcp-teardown if the application suddenly disappears, kill -9). To find out exactly why, your best bet would be if the application that listens to the port you telneted to logs somewhere and looking there for clues.

If this were to be network related you'd be far more likely to see something along the lines of timeout (or nothing happening at all) or connection reset by peer. If this somehow were caused by something along the network, that something would have to sort-of hijack your tcp-session to do the teardown handshake.