I am running a simple WebSocket server on Amazon EC2 (Fedora Core). I've opened the relevant port using ec2-authorize, and checked that it's opened. Iptables is definitely not running. However I can't connect to the port from outside EC2.

I've tried the following (my server is running on port 7000):

telnet ec2-public-dns.xx.xx.xx.amazon.com 7000  

(from within EC2: connects fine)

nmap localhost

(output includes line: 7000/tcp open afs3-fileserver)

telnet ec2-public-dns.xx.xx.xx.amazon.com 7000  

(this time from my local machine: I get "connection refused: Unable to connect to remote host")

The strange thing is this: if I start Nginx on port 7000 then it works and I can connect from outside EC2! And the WebSocket server fails on port 80, where Nginx works fine.

To me this suggests a problem with the WebSocket server, BUT I can connect to it successfully from within EC2. (And it works fine on a different VPS account).

How can I debug this further? If anybody can stop me tearing my hair out, I'd be very grateful indeed :)

link|improve this question
feedback

1 Answer

up vote 1 down vote accepted

is it possible that your service listens only on loopback interface?

on your amazon box run

netstat -lanp|grep LISTEN|grep 7000 

you expect to have something like:

tcp        0      0 0.0.0.0:7000              0.0.0.0:*               LISTEN      2216/abc

rather than

tcp        0      0 127.0.0.1:7000          0.0.0.0:*               LISTEN      13798/abc
link|improve this answer
Ok, this could be it: the output looks like the second line. How can I fix this? – robw Apr 27 '10 at 7:54
Got it: solved this by launching the server on 0.0.0.0, instead of an address resolving to localhost. Seems obvious now. Thanks! – robw Apr 27 '10 at 8:05
feedback

Your Answer

 
or
required, but never shown

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