Ok so it’s 2021. We all know telnet is a dumpster fire no self respecting system engineer wants on their boxes. So what’s the alternative when troubleshooting whether you can connection a port or not. So lets take a look at alternatives below:
Linux with NetCat
nc -zv <hostname or ip> <port number>
If your connection was successful you’ll get a message back like this
Connection to example.com port 80 [tcp/*] succeeded!
If your connection was not successful it will hang until it times out, at which point you’ll get a message indicating it failed with operation timed out.
Windows with Powershell
Test-NetConnection <hostname or ip> -Port <port number> -InformationLevel Quiet
This will return simply a true of false. If you want more detailed information you can use Detailed instead of quiet or simply omit the -InformationLevel flag and everything after it.