Skip to content
Latchkey

telnet: Test a TCP Port by Hand in CI

telnet host port opens a plain TCP connection, so "Connected to" confirms the port is reachable and you can then type protocol commands.

telnet is the everywhere-available way to test a TCP port: if it says "Connected", the port is open; if it says "Connection refused", nothing is listening. It also lets you type an HTTP or SMTP request by hand.

What it does

telnet opens a raw TCP connection to host:port and bridges your terminal to it. The "Connected to" message confirms reachability; what you type is sent, and the server replies are printed. It has no protocol of its own beyond optional telnet negotiation.

Common usage

Terminal
telnet db.internal 5432
# probe an HTTP server by hand
telnet api.internal 80
# then type: GET / HTTP/1.0  (blank line to send)
# escape to the telnet prompt with Ctrl-] then type: quit

Responses

OutputMeaning
Trying <ip>... Connected to <host>.Port is open and accepting connections
Connection refusedHost reachable but nothing listening on that port
Connection timed outPackets dropped (firewall) or host unreachable
telnet: ... Name or service not knownDNS failed to resolve the host

In CI

telnet is interactive, so it is awkward in non-interactive jobs: it does not exit on its own and there is no clean exit code for "open vs closed". For scripted port checks prefer nc -z, which gives an exit status. Use telnet for a quick manual probe in a debug shell.

Common errors in CI

"telnet: Unable to connect to remote host: Connection refused" means the port is closed (service not started). "Connection timed out" means a firewall is dropping the SYN. To leave a stuck session, press Ctrl-] then type quit. "telnet: command not found" on slim images means installing the telnet client or using nc instead.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →