I have blocked a port 8070 by the following command:
sudo iptables -A INPUT -p tcp --destination-port 8070 -j DROP
Now, when I deploy my web application in embedded Tomcat 7 on port 8070, and If I access through the URL http://localhost:8070/app or http://192.168.1.3:8070/app, I always get the exception Connection timed out. That is usual because I have blocked that port.
But when I access the URL http://192.168.1.3:8070/app through the chrome browser, I get the Connection Timed out error message. That is also as expected. But When I try to access http://localhost:8070/app through chrome browser, It gives me successful response. This is unusual.
Why I am able to access through browser on localhost, but not through Apache HttpClient library?
Chrome uses IPv6 so it can resolve localhost using that, the other examples are using IPv4. So check your hosts file if it contains an
::1entry for localhost?You can try with no IPv6 for chrome as well with this command line flag:
--disable-ipv6