Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

POST request not working with IP address of localhost

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

Now the problem I am facing is that when I use following URL for POST the uploaded document then the document is getting uploaded successfully.

http://localhost:8080/ResourceNet/upload

However when I replace 'localhost' with the IP of my machine and use following URL

http://192.168.68.193:8080/ResourceNet/upload

then nothing happens. The POST request never reaches to the REST service. However the GET requests are working properly with URL-2.

Kindly help me out on the following points:

  1. Why POST is not working with IP address of the system but working when 'localhost' is used in place of IP.

  2. Why is it that GET is working properly with IP address is URL but POST is not.

Thanks in advance.

like image 966
Rajeev Singh Avatar asked Nov 12 '22 23:11

Rajeev Singh


1 Answers

One cause might be that the server is bound to localhost and will listen only for requests from localhost, but since you mention GET works it might not be this afteral.

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

like image 197
Bogdan Avatar answered Nov 15 '22 12:11

Bogdan