1
votes

I’ve prepared simple app to test if works on Heroku. Locally seems to works fine, unfortunately on Heroku after some time of loading I receive “Service Unavailable” error. Can someone please advice what is the reason of this error and how to run this app ?

Heroku local web

Locally works fine

Repo on Git: https://github.com/tomaszchmura/OnHeroku

Error on Heroku

Heroku logs:

2020-04-19T06:51:16.211281+00:00 app[web.1]: Server On 5000 2020-04-19T06:52:13.302269+00:00 heroku[web.1]: State changed from starting to crashed 2020-04-19T09:26:59.045884+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=directhero.herokuapp.com request_id=4c36cf02-2713-4ab4-a305-67a0b20eb7c1 fwd="37.30.0.246" dyno= connect= service= status=503 bytes= protocol=https 2020-04-19T09:26:59.663890+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=directhero.herokuapp.com request_id=c5a2bd5c-740c-44d9-bb1e-9baefc20b7a7 fwd="37.30.0.246" dyno= connect= service= status=503 bytes= protocol=https 2020-04-19T09:37:12.003882+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=directhero.herokuapp.com request_id=65f2621c-94ce-4241-95c5-21eac6533218 fwd="37.30.0.246" dyno= connect= service= status=503 bytes= protocol=https 2020-04-19T09:37:12.353987+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=directhero.herokuapp.com request_id=d2afcb89-48a5-4045-a838-af1cb8edd953 fwd="37.30.0.246" dyno= connect= service= status=503 bytes= protocol=https

Can You please advice ?

1

1 Answers

1
votes

You need to listen on port that Heroku provides you in the environment variable

app.listen(process.env.PORT || 5000);

You can access the service on port 80 afterwards!