Hapi server on heroku fails to bind port

2019-04-08 12:48发布

I'm working on a Hapi server for a ReactJS app but when I try to deploy to Heroku, I get the R10 error "Failed to bind to $PORT within 60 seconds of launch". What is going on? I'm using process.env.PORT. I also tried parseInt() around it. Also tried disabling varying packages. The build is successful always.

In the Heroku logs, I see the console log from the index.js ("Hapi running on ...") but then the R10 error shows up and the server restarts, then crashes.

==>

1条回答
\"骚年 ilove
2楼-- · 2019-04-08 13:06

process.env.HOST was undefined on Heroku, and for some reason it didn't like localhost as the host, which caused the issue.

I simply removed the host var all together, so connection looks like:

server.connection({
  port: process.env.PORT || 3000,
  labels: ['api'],
})
查看更多
登录 后发表回答