Inspect text protocols

Test TCP reachability

Interpret a successful or failed connection as narrow evidence about DNS, routing, firewalls, listening ports, and the application.

8 minute lesson

~~~

“Is that port even reachable?” is one of the most common questions in debugging, and a Telnet client answers it in seconds. You can ask it to connect to a specific TCP port:

telnet 127.0.0.1 8000

There are three common outcomes, and each one means something different:

Connected to 127.0.0.1.
telnet: Unable to connect to remote host: Connection refused
telnet: Unable to connect to remote host: Operation timed out

What success proves

A successful connection proves that the client resolved the address, reached the host, completed a TCP handshake, and found something listening on that path. That is four useful facts, and if you were debugging “the app can’t reach the database”, they eliminate DNS, routing, and firewall in one test.

It does not prove that the service is healthy. The application may speak the wrong protocol, reject the next command, return bad data, or wait forever. Something answered the handshake; you know nothing yet about what.

What failure tells you

A refusal usually means the host is reachable but nothing accepted that port. The machine actively answered “no”. Typical causes: the service is not running, it crashed, or it listens on a different port or address. Check the server side with ss -tlnp and compare what is actually bound against what you assumed.

A timeout may point to routing, firewall, address, or silent packet loss. Your packets got no answer at all, and you cannot tell from the client alone whether they never arrived or the replies were dropped. Firewalls that silently discard packets produce exactly this symptom, and it takes noticeably longer to appear than a refusal.

A subtle trap: a refusal from 127.0.0.1 when the service is up sometimes means it bound only to another address. A server listening on 192.168.1.5:8000 refuses loopback connections. The port is fine, the address was wrong.

Preserve the exact result before changing configuration. “Refused” versus “timed out” sends you down entirely different paths, and if you restart three things before reading the message carefully, you have lost the evidence.

Lesson completed

Take this course offline

Get every free book and course as PDF and EPUB files.

Get the download library →