I have a Node.js/Express.js app running on my server that only works on port 3000 and I\'m trying to figure out why. Here\'s what I\'ve found:
I think the best way is to use dotenv package and set the port on the .env
config file without to modify the file www
inside the folder bin
.
Just install the package with the command:
npm install dotenv
require it on your application:
require('dotenv').config()
Create a .env file in the root directory of your project, and add the port in it (for example) to listen on port 5000
PORT=5000
and that's it.
More info here