2
votes

I have a NodeJs application deployed on Heroku.

Since I need to execute to different Procfile in production and development I have installed Foreman for Node (https://www.npmjs.com/package/foreman).

After that I created my .env file and .foreman file and my two Procfile: Profile and Procfile.dev

Executing the command to start the server

nf start -f Procfile.dev

Throws the following error:

Error: listen EADDRINUSE Procfile.dev

That's because Foreman by default select the port 5000. So I inserted this code in the .foreman file:

port: 3003

The problem is that option is still ignored and I still receive the EADDRINUSE error. Even executing the command:

nf start -p 3003 -f Procfile.dev

solve anything, the port is still ignored.

On the other site if I execute command without the -f flag, the port option is not ignored.

How can I solve this?

1

1 Answers

0
votes

On Heroku, you can't specify what port you want to bind to -- Heroku will tell you what port you can use.

Heroku does this by creating an environment variable for you called PORT.

So, in order to make your web server work, you need to have foreman start your web server on the port specified in the PORT environment variable.