node.jshttpamazon-ec2pm2port-number

How to run Node/Express App on port 3001, 3002 etc?


We are using 4 different express projects in a single server, running pm2 start cmd from each project root directory to start the app.

And using ec2 Linux server, added port 3000, 3001 to inbound rules, both runs fine but not able to access API's through 3001, and able access by 3000, what could be an Issue?

the same project running at 3000, but not in 3001, so we can confirm, there is no bug in our projects.

Tried at terminal nodemon app it runs fine but not accessed by Postman getting same error :

Could not get any response

There was an error connecting to http://ec2-x-x-amazonaws.com:3001/api/login.

how can we run multiple node/express projects in available/defined ports?

3001    tcp 0.0.0.0/0, ::/0 ✔
3000    tcp 0.0.0.0/0, ::/0 ✔

Some ports running without add as an inbound rule like 8088, 8089.

pm2 status shows all ports are running fine.

enter image description here

The pm2 list is above and id 8 have port number 3001


Solution

  • This is a port number issue, re-checked from server inbound rules, whether the port 3001 and 3002 etc added correctly with custom TCP rule and source must be anywhere. now runs fine.

    ec2-Instances -> launch-wizard-1 -> right click -> edit inbound rules.