Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I attempted to start tomcat7 on an EC2 instance running AMI and could not get the web service accessed from a browser using the public IP.

  1. Created an EC2 instance with default AMI as the image
  2. Created an Elastic IP and associated it with the instance
  3. Installed tomcat7 and made sure that it is started in inet.d
  4. Created an entry in Security Group for quick-start-1 and added port 8080 to it.
  5. Verified the Security Group is properly added to the instance.
  6. Verified that the tomcat is on Port 8080

Can't access the http server from a browser using the public DNS name or the IP address.

Some of the output from the instance are shown below:

ec2-user@ip-10-202-49-142 ~$ sudo fuser -n tcp 8080
8080/tcp: 1162

 

ec2-user@ip-10-202-49-142 ~$ sudo netstat -apn
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1019/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1088/sendmail
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1052/sshd
tcp 0 300 10.202.49.142:22 198.6.50.15:28002 ESTABLISHED 1253/sshd
tcp 0 0 ::1:631 :::* LISTEN 1019/cupsd
tcp 0 0 ::ffff:127.0.0.1:8005 :::* LISTEN 1162/java
tcp 0 0 :::8009 :::* LISTEN 1162/java
tcp 0 0 :::8080 :::* LISTEN 1162/java
tcp 0 0 :::22 :::* LISTEN 1052/sshd
udp 0 0 0.0.0.0:68 0.0.0.0:* 928/dhclient
udp 0 0 0.0.0.0:631 0.0.0.0:* 1019/cupsd
udp 0 0 10.202.49.142:123 0.0.0.0:* 1073/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 1073/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 1073/ntpd
udp 0 0 fe80::1031:3bff:fe12:326:123 :::* 1073/ntpd
udp 0 0 ::1:123 :::* 1073/ntpd
udp 0 0 :::123 :::* 1073/ntpd
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 ACC STREAM LISTENING 3054 1237/gam_server @/tmp/fam-root-
unix 2 ACC STREAM LISTENING 1072 1/init @/com/ubuntu/upstart
unix 7 [ ] DGRAM 1882 978/rsyslogd /dev/log
unix 2 ACC STREAM LISTENING 2408 1019/cupsd /var/run/cups/cups.sock
unix 2 ACC SEQPACKET LISTENING 1139 584/udevd @/org/kernel/udev/udevd
unix 2 ACC STREAM LISTENING 1936 999/dbus-daemon /var/run/dbus/system_bus_socket
unix 2 [ ] DGRAM 3935 1318/sudo
unix 3 [ ] STREAM CONNECTED 3124 1253/sshd
unix 3 [ ] STREAM CONNECTED 3123 1256/sshd
unix 2 [ ] DGRAM 3120 1253/sshd
unix 3 [ ] STREAM CONNECTED 3057 1237/gam_server @/tmp/fam-root-
unix 3 [ ] STREAM CONNECTED 3056 1235/python
unix 3 [ ] STREAM CONNECTED 3041 999/dbus-daemon /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 3040 1235/python
unix 2 [ ] DGRAM 2780 1171/crond
unix 2 [ ] DGRAM 2663 1096/sendmail: Queu
unix 2 [ ] DGRAM 2645 1088/sendmail
unix 2 [ ] DGRAM 2566 1073/ntpd
unix 3 [ ] STREAM CONNECTED 1945 999/dbus-daemon /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 1944 1/init
unix 3 [ ] STREAM CONNECTED 1940 999/dbus-daemon
unix 3 [ ] STREAM CONNECTED 1939 999/dbus-daemon
unix 3 [ ] DGRAM 1155 584/udevd
unix 3 [ ] DGRAM 1154 584/udevd

 

ec2-user@ip-10-202-49-142 ~$ sudo iptables --list
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ec2-user@ip-10-202-49-142 ~$ 
share|improve this question
    
It looks like tomcat is correctly listening on the public IP address, and that the default local firewall is ACCEPT, hence this is much likely the security-groups settings. Can you paste in the output of $ euca-describe-groups or whatever tool you are using to add the rules. –  Tom H May 11 '12 at 22:09
add comment

1 Answer

Looks like there is only a ipv6 tomcat socket and not an ipv4

:::8080 :::* LISTEN 1162/java
share|improve this answer
    
Where do I change this? I think there is a flag to Java startup -Djava.net.preferIPv4Stack=true but what is the best way to force the starup of tomcat to pass this option to java startup? Thanks. –  aws-user59 May 11 '12 at 23:44
    
Okay - I figured out how to force the tomcat to bind to an IPv4 address by addding a line CATALINA_OPTS="-Djava.net.preferIPv4Stack=true" to the tomcat7.conf. But that still did not solve the problem. [ec2-user@ip-10-202-49-142 conf]$ sudo fuser -n tcp 8080 8080/tcp: 1580 [ec2-user@ip-10-202-49-142 conf]$ sudo netstat -apn | grep :8080 tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1580/java –  aws-user59 May 12 '12 at 0:06
    
Can you check your server.xml and make sure port 8080 is a BIO (HTTP) port and not an NIO (AJP) port? –  Izac May 12 '12 at 7:51
    
lzac, not sure how I can make sure of this. The sever.xml has: <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> and <Connector executor="tomcatThreadPool" port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> –  aws-user59 May 14 '12 at 22:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.