POST request does not work with localhost IP

I have a REST web service hosted on tomcat-7 on my local machine. I have an application that uploads a file to a REST service.

Now the problem that I am facing is that when I use the following URL to POST the loaded document, the document loads successfully.

http://localhost:8080/ResourceNet/upload 

However, when I replace "localhost" with the IP address of my machine and use the following URL

 http://192.168.68.193:8080/ResourceNet/upload 

then nothing happens. A POST request never reaches the REST service. However, GET requests work correctly with URL-2.

Please help me in the following points:

  • Why POST does not work with the IP address of the system, but it works when "localhost" is used instead of IP.

  • Why does GET work correctly, and the IP address is the URL, but the POST is not.

Thanks in advance.

+4
source share
1 answer

One of the reasons may be that the server is bound to the local host and will only listen for requests from localhost, but since you mention that GET is working, this might not be the last.

Another thing I will check is a firewall on your PC or network. The fact is that localhost is a loopback address , so it does not enter the network when you use it. Using the actual IP address of the PC goes to the network and goes back to the PC. Maybe a proxy or firewall drops POST and only allows GET?

+1
source

All Articles