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
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: quitResponses
| Output | Meaning |
|---|---|
| Trying <ip>... Connected to <host>. | Port is open and accepting connections |
| Connection refused | Host reachable but nothing listening on that port |
| Connection timed out | Packets dropped (firewall) or host unreachable |
| telnet: ... Name or service not known | DNS 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.