0

My node app worked fine when I hosted it in Glitch and DigitalOcean server. But it doesn't work when I try in Heroku.

Here's the log I get after running heroku logs --tail:

› Warning: heroku update available from 7.35.0 to 7.39.5. 2020-04-24T18:56:56.066168+00:00 app[api]: Initial release by user cuinjune@gmail.com 2020-04-24T18:56:56.167629+00:00 app[api]: Enable Logplex by user cuinjune@gmail.com 2020-04-24T18:56:56.167629+00:00 app[api]: Release v2 created by user cuinjune@gmail.com 2020-04-24T18:56:56.066168+00:00 app[api]: Release v1 created by user cuinjune@gmail.com 2020-04-24T18:57:07.000000+00:00 app[api]: Build started by user cuinjune@gmail.com 2020-04-24T18:57:25.352788+00:00 app[api]: Deploy 1958e9f7 by user cuinjune@gmail.com 2020-04-24T18:57:25.370743+00:00 app[api]: Scaled to web@1:Free by user cuinjune@gmail.com 2020-04-24T18:57:25.352788+00:00 app[api]: Release v3 created by user cuinjune@gmail.com 2020-04-24T18:57:26.000000+00:00 app[api]: Build succeeded 2020-04-24T18:57:30.065364+00:00 app[web.1]: 2020-04-24T18:57:30.065389+00:00 app[web.1]: > battle-square@1.0.0 start /app 2020-04-24T18:57:30.065389+00:00 app[web.1]: > node index.js 2020-04-24T18:57:30.065390+00:00 app[web.1]: 2020-04-24T18:57:30.206325+00:00 app[web.1]: Server is running localhost on port: 3000 2020-04-24T18:58:28.351045+00:00 heroku[web.1]: State changed from starting to crashed 2020-04-24T18:58:28.354624+00:00 heroku[web.1]: State changed from crashed to starting 2020-04-24T18:58:33.378248+00:00 app[web.1]: 2020-04-24T18:58:33.378282+00:00 app[web.1]: > battle-square@1.0.0 start /app 2020-04-24T18:58:33.378283+00:00 app[web.1]: > node index.js 2020-04-24T18:58:33.378283+00:00 app[web.1]: 2020-04-24T18:58:33.576646+00:00 app[web.1]: Server is running localhost on port: 3000 2020-04-24T18:58:52.316240+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=secure-eyrie-48591.herokuapp.com request_id=6ee36c25-45d3-4e0a-aae0-c9ddc89e1b69 fwd="69.116.190.29" dyno= connect= service= status=503 bytes= protocol=https 2020-04-24T18:59:31.070175+00:00 heroku[web.1]: State changed from starting to crashed 2020-04-24T18:59:38.566167+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=secure-eyrie-48591.herokuapp.com request_id=55127020-5b19-4154-885f-79287266284a fwd="69.116.190.29" dyno= connect= service= status=503 bytes= protocol=https 2020-04-24T18:59:39.185406+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=secure-eyrie-48591.herokuapp.com request_id=0f99d119-de28-4e80-a22d-0dab655469f7 fwd="69.116.190.29" dyno= connect= service= status=503 bytes= protocol=https 2020-04-24T19:00:26.640037+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=secure-eyrie-48591.herokuapp.com request_id=462f5dd6-c6ee-42d2-9251-50894d822936 fwd="69.116.190.29" dyno= connect= service= status=503 bytes= protocol=https 2020-04-24T19:00:27.065538+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=secure-eyrie-48591.herokuapp.com request_id=5e8e1903-9520-4c1e-a468-aecb35ba453f fwd="69.116.190.29" dyno= connect= service= status=503 bytes= protocol=https 2020-04-24T19:06:10.144325+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=secure-eyrie-48591.herokuapp.com request_id=ca404bc9-b117-42c9-82db-db08862572a8 fwd="69.116.190.29" dyno= connect= service= status=503 bytes= protocol=https 2020-04-24T19:06:10.679020+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=secure-eyrie-48591.herokuapp.com request_id=c18910bc-34ad-4ae0-8d88-b1dfbfed00f9 fwd="69.116.190.29" dyno= connect= service= status=503 bytes= protocol=https

And here's the link to my repo: https://github.com/cuinjune/battle-square

What's the problem and how to fix this?

Zack Lee
  • 2,784
  • 6
  • 35
  • 77

1 Answers1

1

The cause is in the logs: Server is running localhost on port: 3000.

The app is using port 3000, locally is fine but Heroku gives you a dynamic port upon deployment, therefore you need to bind to this port which is provided through the env variable $PORT

Beppe C
  • 11,256
  • 2
  • 19
  • 41