简体   繁体   中英

Heroku Web process failed to bind to $PORT within 60 seconds of launch

i am making an application in angular, runs fine locally but when i try to deploy it with heroku, shows the next error:

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

the code looks like this:

const express= require('express'),
path= require('path');

const app =express();

app.use(express.static('./dist/re-mi'));

app.get('/*', (req,res)=>{
res.sendFile(path.join(__dirname, '/dist/myapp/index.html'));
});

var port_number = server.listen(process.env.PORT || 3000);
app.listen(port_number);

i also see other questions with the same error but no answer works for me

It looks like the port_number variable you have is not set correctly. If your full code is posted, then the variable server is not defined anywhere. That is from the line

var port_number = server.listen(process.env.PORT || 3000);

Even if server is defined, it seems unlikely that server.listen would return the port number that it is listening on. I think you would want:

var port_number = process.env.PORT || 3000;
app.listen(port_number);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM