I’m using the following to start a Node app on Cloud9 without getting the dreaded wrong port or IP warning, which I get unless I specify the IP address as process.env.IP
:
app.listen(PORT, process.env.IP || 'localhost', function () {
console.info(`Server listening on ${this.address().address}:${this.address().port}`);
}).on("error", err => {
console.error(err);
});
However, I’m wondering when I deploy this to Heroku and process.env.IP is undefined, is it O.K. that the IP will default to localhost
on Heroku?
When I try running this on Heroku, I get this from the console.info:
Server listening on 127.0.0.1:23128
but then I get the following errors in the Heroku log:
2018-05-31T04:36:26.982797+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-05-31T04:36:26.982904+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-05-31T04:36:27.097924+00:00 heroku[web.1]: State changed from starting to crashed
2018-05-31T04:36:27.074917+00:00 heroku[web.1]: Process exited with status 137
2018-05-31T04:37:18.807726+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ancient-anchorage-15597.herokuapp.com request_id=f893c181-f406-4319-b2f2-938548ba4ff0 fwd="72.0.178.64" dyno= connect= service= status=503 bytes= protocol=https