Ubuntu – Node.js Site is Refusing Connection

node.jsUbuntu

I have a fresh Ubuntu instance setup on Amazon EC2. This instance has a node web server on it. When I try to hit my web site, I get an error in my browser. The error is:

Connect: Connection refused

I've confirmed that I can ping the machine. Yet when I enter http://[ipAddress] or http://[ipAddress]:8080 in my browser, I get the error above. When I start the node web server, it says:

Server listening on 8080

I implemented port forwarding using the following command:

iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 
-j REDIRECT --to-port 8080

I believe I opened the firewall appropriately using the following commands:

iptables -A INPUT -p tcp -m tcp --sport 80 -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --dport 80 -j ACCEPT

I'm stuck. I do not know why I'm getting a "Connection refused." I would sincerely appreciate any help or insights that someone can provide. At this point, I not sure if this message is coming from Ubuntu or from the Node server. Beyond that, I'm unfamiliar with how to track this issue down.

Thank you for your help. It means a lot to me.

Best Answer

Your server is most likely not listening on [ipAddress]:8080 is likely only listening on localhost:8080. You can check this using netstat You will need to configure your server to listen on all/appropriate IP addresses. No doubt how to do this will be in the documentation.

Related Topic