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?
Note, that this should be on serverfault.com .
But you should try indicating your network interface for iptables
like this:
iptables -A INPUT -p tcp -s 192.168.1.3 --destination-port 8070 -j DROP
iptables -A INPUT -p tcp -s localhost --destination-port 8070 -j DROP
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 ::1
entry for localhost?
You can try with no IPv6 for chrome as well with this command line flag:
--disable-ipv6
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.