How Do You Test if a REST API Call Is Reaching a Linux Server?

Problem scenario
You have a Linux server with a web service listening on port 443 (or some other port). You are not sure if another server can reach this Linux server. There could be firewall issues or network problems restricting connectivity on a given port. You have used ping to test connectivity. You have used nmap to verify the port is listening. But you are not 100% sure the REST calls are reaching the intended server on the correct port (e.g., because of port forwarding or behind the scenes there could be some other problem). How do you test the connections in a non-theoretical way?

Solution
Prerequisite
You must have tcpdump installed. For a typical Debian/Ubuntu server, it will already be installed. On CentOS/RHEL/Fedora you could run this command to install it: sudo yum -y install tcpdump

Procedures
Step #1
On the server that is listening for a call over port 443, run this command (which will appear to hang):

sudo tcpdump -i any port 443

Step #2
While looking at the terminal of the above command, go to the server that needs to perform a GET or POST call on port 443. Have that server perform the operation to invoke the REST call on port 443.

You will see corresponding activity every time in real time (excepting only for the latency between the server making the REST calls and your listening Linux server). You can use a different port number in the above command to match the port you expect the REST call to use.

Leave a comment

Your email address will not be published. Required fields are marked *