1

Can't access node.js API on port 3000 on AWS EC2 instance, but netstat shows port :3000 listening and my AWS security group has TCP rules for this port. What else could the problem be?

I've tried changing port, setting security group rules and adding port to iptables and it didn't work. I'm using node 10.6.0.

When I use netstat -tulpn | grep LISTEN it contains the following line:

tcp        0      0 127.0.0.1:3000              0.0.0.0:*                   LISTEN      8270/node

netstat print

Security Group Inbound Rules

When i try to access myip:3000/socket (my node endpoint) it shows: ERR_CONNECTION_REFUSED

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • 2
    Looks like node is listening on loopback only, like shown in the netstat output. It should look like `tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 8270/node` or `tcp 0 0 :::3000 0.0.0.0:* LISTEN 8270/node`, so use `server.listen(3000)` instead – Lawrence Cherone Jun 26 '19 at 01:01
  • See https://stackoverflow.com/questions/14043926/node-js-connect-only-works-on-localhost and https://stackoverflow.com/questions/33837563/how-to-not-use-localhost-but-the-ip-of-the-server-instead – jarmod Jun 26 '19 at 01:37
  • 1
    Solved the problem, thanks guys, completely forgot to change from 127.0.0.1(on my dev enviroment) to 0.0.0.0 on deploying – Matheus de Souza Jun 26 '19 at 02:36
  • Thank you! This was the answer^ – vijayxtreme Mar 12 '20 at 20:38

0 Answers0