Thursday, May 21, 2015

Tomcat Not Accessible Outside Due To Blocked Port

You have installed Tomcat in your Linux machine. You can access it inside the machine using localhost:8080 or 127.0.0.1:8080. But when you try to connect to it remotely from another machine, socket connection is timing out and you are not able to access tomcat. That can be because of that specific port is blocked in Linux firewall. There's an easy way to check. Try to create a telnet connection to the specific host and port like:
telnet host-name 8080
If the connection is denied or you get a timeout, then the port is not open. So now question is how you can open the port from Linux firewall. To open a port for TCP connection is easy in Linux machine. You just have to use iptables program. Open a command line. Type below command:
iptables -I INPUT -p tcp --dport 8080 --syn -j ACCEPT
That's all. Now you can try to access tomcat on port 8080 remotely and it should work.
You may want to execute the following command after this:
service iptables save
This will persist the changes you made in iptables across system restarts.

1 comment:

  1. Thanks for sharing the useful information.Being working as a research paper writer in one of the world's best research writing service,i have been using the tomcat for my personal projects and all. So,this will be very helpful for me to be aware about what are the precautions need to be done to prevent the blocking of IP's.

    ReplyDelete