I am trying to push my app to heroku bu I am getting this problem where I am using the correct port number using the process.env.PORT variable but still I am getting this error message:
heroku[web.1]: Starting process with command `node app.js`
app[web.1]: info - socket.io started
app[web.1]: Express server listening on port 49559 in development mode
heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 10843, should be 49559 (see environment variable PORT)
heroku[web.1]: Stopping process with SIGKILL
heroku[web.1]: Process exited
You can see in this error message that app is using the right port but still heroku shows the bad bind error. Any help is appreciated.
Heroku will pass the port in a environment variable named PORT
, which means you can access it via process.env
.
Simply change your code to call listen
with the proper port
var port = process.env.PORT || 3000;
app.listen(port);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With