简体   繁体   中英

How to bind port in Heroku With Node.js

Heroku makes error like this

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

I think port isn't make trouble But many documents say timeout is port trouble

My code

const port = process.env.port || 8080;
app.listen(port, () => {
    console.log(process.env.port);
    console.log(`SERVER is running at ${port}`);
})

To use environmental variables on Heroku you need to set them in the dashboard. Open https://dashboard.heroku.com/apps/YOUR_APP_NAME/settings , then click the REVEAL CONFIG VARS button. After that, you should get a possibility to set up environmental variables. Also, if you use the .env file you need to remove it.

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