'Heroku Node.js Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

I found a dozen solutions for Express powered apps with setting port to listen on. But I have an app that doesn't use Express and doesn't in fact listens anything. And after 60 seconds of it successfully running I get a Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch message. How I can get around it? Thanks.



Solution 1:[1]

If your app doesn't listen any port then you should use another type of app in you Procfile, I mean in Procfile you have:

web: node app.js

replace it with:

worker: node app.js

"web" type of application means that your app MUST listen some port

Solution 2:[2]

Another way would be changing the dynos from web (standard setting regardless of the settings in Procfile) to worker with these commands:

heroku ps:scale web=0
heroku ps:scale worker=1

Sometimes Heroku ignores settings in the Procfile.

Solution 3:[3]

This comment solved my issue: https://stackoverflow.com/a/67787556/8684435

The issue is the way you define the port, it always runs on 3001 which is not possible on Heroku, you need to bind the $PORT env variable. Change your code to check the first fi the process.env.PORT is defined (it will be on Heroku but on your local dev environment it will default to 3001)

app.listen(process.env.PORT || 3001, '0.0.0.0', () => {
  console.log("Server is running.");
});

Solution 4:[4]

I have the same issue:

Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

I tried many things.

The following works without using express:

http.createServer(onRequest).listen(process.env.PORT || 6000)

Solution 5:[5]

I also got the same the same problem: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

flowing work in my pc windows 10 visual studio code

app.listen(process.env.PORT || 8080);

also added these three line in package.json

"worker": "node index.js", "start": "node index.js" "test": "node test.js"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Devid Farinelli
Solution 2
Solution 3 WaterTrash
Solution 4 Alexander Ciesielski
Solution 5