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.

- 1,041
- 2
- 11
- 23
6 Answers
After lots of googling I decided to npm install express
and add
var express = require('express');
var app = express();
app.set('port', (process.env.PORT || 5000));
//For avoidong Heroku $PORT error
app.get('/', function(request, response) {
var result = 'App is running'
response.send(result);
}).listen(app.get('port'), function() {
console.log('App is running, server is listening on port ', app.get('port'));
});
This fixed the error, even though I don't like adding express just to avoid one error. If someone finds a better solution, please let me know.

- 1,041
- 2
- 11
- 23
-
9I'm not sure what's the best solution here, but one thing I know (that did work) was to use Node.js built-in module `http` instead of requiring express module. ```var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.send('it is running\n'); }).listen(process.env.PORT || 5000); ``` – Okazaki Miyama Yuta Sep 07 '15 at 09:35
-
2Look at the answer below about changing your procfile and scaling your dynos by @pille. It is much better than this answer as it is not a workaround but the correct way to do it. – otusweb Mar 20 '17 at 14:16
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

- 7,514
- 9
- 42
- 73

- 780
- 6
- 9
-
4
-
@Pille, have you installed [node-foreman](https://github.com/strongloop/node-foreman)? – Navidot Dec 08 '16 at 14:42
-
In my case it was `worker: npm start`, but the idea remains the same. It worked, thanks a lot! – Bugs Bunny Dec 19 '16 at 12:56
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.

- 1,123
- 4
- 16
- 38
-
2The second command failed for me. I had to set up `worker: npm start` in my Procfile first. – Bugs Bunny Dec 19 '16 at 12:56
-
This worked for me, well it didn't to begin with until I removed the heroku ps:scale web=0 line, thanks! – spences10 Jan 03 '17 at 12:33
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.");
});

- 428
- 1
- 6
- 13
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)

- 10,506
- 5
- 45
- 66

- 224
- 2
- 17
-
-
I have the same issue, but I use AdonisJS and I can't edit this line... – pirmax Jan 19 '18 at 15:36
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"

- 11
- 4