Sometimes you need to check if a port is open and available e.g. not firewalled, from your current location.
The following netcat command will instantly tell you if you a port is open and you can connect to it on a remove server:
netcat -w1 -z -v <HOST> <PORT>
E.g.:
netcat -w1 -z -v bash-prompt.net 443
If the port is open you’ll get the following response:
$ netcat -w1 -z -v bash-prompt.net 443
bash-prompt.net [5.161.150.90] 443 (https) open
And if it’s closed:
$ netcat -w1 -z -v bash-prompt.net 21
bash-prompt.net [5.161.150.90] 21 (ftp): Connection timed out