I have an AWS ec2 instance. I have installed tomcat and now want to access it via the browser on port 8080. When I try to do so, the browser hangs. I HAVE ADDED 8080 TO THE DEFAULT SECURITY GROUP. I see that you can open different ports for different regions, I have added the port for every region.

Here is what I've done so far:

//install tomcat
# sudo yum install tomcat6
//open port on server

# sudo iptables -A INPUT -i eth0 -p tcp --sport 8080 -m state --state NEW,ESTABLISHED -j ACCEPT


//start tomcat

# sudo service tomcat6 start

//and rule to AWS security group for port 8080
AWS dashboard > ec2 > security groups > default group > inbound rule: 8080 (HTTP*) 0.0.0.0/0


//check via cli that tomcat is running on port 8080
# udo fuser -v 8080/tcp

(successful response) 8080/tcp:            tomcat    16353 F.... java

//check via browser
http://ec2-instance-dns:8080 (browser tries to load page indefinitely)

Solution 1:

You also need to add the port in the security group in the AWS-config-panel.

enter image description here

Solution 2:

By default AWS EC2 instances have a security group that doesn't allow access other than SSH. You have to go and configure the security group to allow what traffic you want to allow into the instances. The browser hang you are experiencing is because of the AWS firewall not being configured to allow port 8080/tcp through so it is dropping the packets and your browser is just waiting for the response to the TCP handshake which will never happen.

Eliminate as many moving variables... Disable iptables firewall. If it works then your security group is configured properly and your iptables rule which has --sport 8080 rather than --dport 8080 would be at fault. Your udo ... command would have more than likely utilized the loopback interface if you ran it from the EC2 instance itself so it would have ignored any iptables rule affecting eth0 only.