Test TCP connectivity with curl
You probably know about curl command: it’s great for downloading web pages or files from a Unix command line. But there’s another great usage curl command has: testing TCP ports connectivity.
Say, you’re helping with some firewall changes and need to confirm that connection from your server to some remote host and specific TCP port still works.
Here’s a quick video from UnixTutorial.TV channel of mine:
Here’s how you can do it using curl command and its telnet functionality.
Test SSH port connection with curl
In this example, SSH connection works because:
- We get the “Connected” status
- We see the SSH version prompt: SSH-2.0-OpenSSH_7.4
Test jBoss port 8080 with curl
This scenario shows that connection is refused (probably because there’s no service running on that port).
IMPORTANT: you would probably get a different message if firewall blocks the 8080 port. Connection refused is a clear sign that port is accessible, but nothing’s responding on it.
See Also
- curl command
- Using wget and curl
- Basic Unix Commands
- iptables: keep rules after reboot
- Advanced Unix Commands
You probably know about curl command: it’s great for downloading web pages or files from a Unix command line. But there’s another great usage curl command has: testing TCP ports connectivity.
Say, you’re helping with some firewall changes and need to confirm that connection from your server to some remote host and specific TCP port still works.
Here’s a quick video from UnixTutorial.TV channel of mine:
Here’s how you can do it using curl command and its telnet functionality.
Test SSH port connection with curl
In this example, SSH connection works because:
- We get the “Connected” status
- We see the SSH version prompt: SSH-2.0-OpenSSH_7.4
Test jBoss port 8080 with curl
This scenario shows that connection is refused (probably because there’s no service running on that port).
IMPORTANT: you would probably get a different message if firewall blocks the 8080 port. Connection refused is a clear sign that port is accessible, but nothing’s responding on it.
See Also
- curl command
- Using wget and curl
- Basic Unix Commands
- iptables: keep rules after reboot
- Advanced Unix Commands