2

Up until this morning my Node server (EC2 Amazon Linux) was working fine. I fire it up npm start ./bin/www, then connect to it from my browser and its been fine for more than year, no hiccups.

This morning it keeps saying ERR Connection Refused. My server says Connected to 3000. Netstat says 3000 is open but whenever I try to connect it says refused. Have no idea whats going on. It's like its not even reaching Node server. I don't have any other servers running. It seems like the problem is with security groups but port 80 is open to all sources and I added now 8080 also.

enter image description here

Amazon security group

Node server bin/www

Marina Dunst
  • 859
  • 1
  • 6
  • 19
  • I tried to ping it from a windows terminal. I can successfully ping the domain name provided by namecheap but can't ping the IP address (elastic IP from Amazon EC2) yet I can connect to this IP address with Putty – Marina Dunst Sep 25 '17 at 22:24
  • I'm wondering if port 80 should be listed in netstat? I never used netstat before so don't know how it was before. – Marina Dunst Sep 25 '17 at 22:27
  • Just a hint for life: "Don't use ping as a tool to check if a server is up or not." [Ping](https://en.wikipedia.org/wiki/Ping_(networking_utility)) uses the ICMP protocol, if you don't allow it on your security group and inside your machine to respond to it, it will never answer. – aderubaru Sep 25 '17 at 22:42
  • I don't see port 3000 open in your security group. Is the image truncated? – jarmod Sep 25 '17 at 23:22
  • @jarmod I never had 3000 in the list and it worked fine. When the problem started I added it and it didn't make any difference. I added it now again and still no luck. – Marina Dunst Sep 25 '17 at 23:52
  • The security group you've shown us doesn't have port 22 configured either, and yet you're running netstat on that instance so you presumably do have SSH access. Any chance that you are looking at the wrong security group? – jarmod Sep 25 '17 at 23:59
  • @jarmod. Thanks, yes I am using Putty to login and it still works as before. I can start the node server, use linux etc. I checked the security group settings too, it is the "default" and it's tied to the instance that I'm running. – Marina Dunst Sep 26 '17 at 00:21
  • 1
    Maybe there are some cause: check IPtable `iptables -L -n -v` to make sure there is no any deny on port 80. In your server must there are one service listen port 80 => it must be shown in `netstat -tulpn` – Bui Anh Tuan Sep 26 '17 at 00:22
  • @TuanBA That's what I thought i.e. that port 80 supposed to be in netstat. I ran iptables and it says: Could not insert iptables, operation not permitted, iptables v1.4.18 cant initialize iptables ip filter: Table does not exist. Perhaps iptables or your kernel needs to be upgraded. --- Any other options I can use besides iptables? – Marina Dunst Sep 26 '17 at 00:29
  • You need root permission to execute `iptables`. I can run this command in my `amazon linux server`. `Netstat` cannot snip port 80 maybe there is no service running on port 80. In the past, did you use something like `varnish or nginx` to forward fort 80 -> 3000? If yes, maybe that service was stoped. – Bui Anh Tuan Sep 26 '17 at 00:36
  • One more thing, try to use `netcat or telnet` command to check connection, do not use `ping`. Example: `nc -v -w IP PORT` – Bui Anh Tuan Sep 26 '17 at 00:44
  • @TuanBA When I do netcat IP PORT it says connection refused. Ok I think thats where the problem is. I don't have any other servers running except Node (or so I think). I thought Amazon Linux was configured by default to forward requests 80-> 3000. Will look into how to fix it. Thank you! – Marina Dunst Sep 26 '17 at 01:10

0 Answers0