0

I have tried to use Heroku for my Continuous Intergration/Deployment on a project. I tried to follow a simple youtube video for uploading my node.JS application, I got right to the end where you click on view app via Heroku and I got a huge error log (as seen below), which I have no idea where to start debugging, can anyone shed some light?

Kayleighs-MBP:SOFT355-HangMan Kayleigh$ heroku logs --tail
 ›   Warning: heroku update available from 7.35.0 to 7.35.1.
2020-01-04T14:05:16.981790+00:00 app[api]: Enable Logplex by user kayz_haydock@hotmail.co.uk
2020-01-04T14:05:16.822338+00:00 app[api]: Release v1 created by user kayz_haydock@hotmail.co.uk
2020-01-04T14:05:16.981790+00:00 app[api]: Release v2 created by user kayz_haydock@hotmail.co.uk
2020-01-04T14:05:16.822338+00:00 app[api]: Initial release by user kayz_haydock@hotmail.co.uk
2020-01-04T14:18:46.000000+00:00 app[api]: Build started by user kayz_haydock@hotmail.co.uk
2020-01-04T14:19:18.680353+00:00 app[api]: Release v3 created by user kayz_haydock@hotmail.co.uk
2020-01-04T14:19:18.680353+00:00 app[api]: Deploy ff30f369 by user kayz_haydock@hotmail.co.uk
2020-01-04T14:19:18.695708+00:00 app[api]: Scaled to web@1:Free by user kayz_haydock@hotmail.co.uk
2020-01-04T14:19:20.000000+00:00 app[api]: Build succeeded
2020-01-04T14:19:22.117990+00:00 heroku[web.1]: Starting process with command `npm start`
2020-01-04T14:19:25.409179+00:00 app[web.1]: 
2020-01-04T14:19:25.409202+00:00 app[web.1]: > SOFT355-HangMan@1.0.0 start /app
2020-01-04T14:19:25.409204+00:00 app[web.1]: > node hangman-server.js
2020-01-04T14:19:25.409205+00:00 app[web.1]: 
2020-01-04T14:19:56.058173+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: MongoTimeoutError: Server selection timed out after 30000 ms
2020-01-04T14:19:56.058209+00:00 app[web.1]: at Timeout._onTimeout (/app/node_modules/mongodb/lib/core/sdam/server_selection.js:308:9)
2020-01-04T14:19:56.058212+00:00 app[web.1]: at listOnTimeout (internal/timers.js:531:17)
2020-01-04T14:19:56.058214+00:00 app[web.1]: at processTimers (internal/timers.js:475:7)
2020-01-04T14:19:56.058439+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
2020-01-04T14:19:56.058598+00:00 app[web.1]: (node:23) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2020-01-04T14:20:22.338538+00:00 heroku[web.1]: State changed from starting to crashed
2020-01-04T14:20:22.407927+00:00 heroku[web.1]: State changed from crashed to starting
2020-01-04T14:20:22.219187+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-01-04T14:20:22.219426+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-01-04T14:20:22.325559+00:00 heroku[web.1]: Process exited with status 137
2020-01-04T14:20:25.204227+00:00 heroku[web.1]: Starting process with command `npm start`
2020-01-04T14:20:27.500815+00:00 app[web.1]: 
2020-01-04T14:20:27.500828+00:00 app[web.1]: > SOFT355-HangMan@1.0.0 start /app
2020-01-04T14:20:27.500830+00:00 app[web.1]: > node hangman-server.js
2020-01-04T14:20:27.500831+00:00 app[web.1]: 
2020-01-04T14:20:38.708137+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=soft355-hangman-heroku.herokuapp.com request_id=15d0e236-af32-44ae-aae8-5a6cb342c260 fwd="90.200.113.10" dyno= connect= service= status=503 bytes= protocol=https
2020-01-04T14:20:57.961209+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: MongoTimeoutError: Server selection timed out after 30000 ms
2020-01-04T14:20:57.961225+00:00 app[web.1]: at Timeout._onTimeout (/app/node_modules/mongodb/lib/core/sdam/server_selection.js:308:9)
2020-01-04T14:20:57.961228+00:00 app[web.1]: at listOnTimeout (internal/timers.js:531:17)
2020-01-04T14:20:57.961229+00:00 app[web.1]: at processTimers (internal/timers.js:475:7)
2020-01-04T14:20:57.961471+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
2020-01-04T14:20:57.961541+00:00 app[web.1]: (node:23) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2020-01-04T14:21:25.939157+00:00 heroku[web.1]: State changed from starting to crashed
2020-01-04T14:21:25.848388+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-01-04T14:21:25.848490+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-01-04T14:21:25.924978+00:00 heroku[web.1]: Process exited with status 137
2020-01-04T14:21:28.031213+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=soft355-hangman-heroku.herokuapp.com request_id=84fc9ea0-a4e9-4c65-8357-2ef4218f2054 fwd="90.200.113.10" dyno= connect= service= status=503 bytes= protocol=https
2020-01-04T14:21:28.670209+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=soft355-hangman-heroku.herokuapp.com request_id=ab8bb069-da76-4766-830f-e81a80dce8d3 fwd="90.200.113.10" dyno= connect= service= status=503 bytes= protocol=https
2020-01-04T14:21:29.277077+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=soft355-hangman-heroku.herokuapp.com request_id=66dbc233-0e2f-4c39-ba98-3cae75ae03b7 fwd="90.200.113.10" dyno= connect= service= status=503 bytes= protocol=https
2020-01-04T14:24:34.028234+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=soft355-hangman-heroku.herokuapp.com request_id=3fb5fa25-9a46-4b11-b5b0-5df9483c1eed fwd="90.200.113.10" dyno= connect= service= status=503 bytes= protocol=https
Sunny0101
  • 444
  • 1
  • 5
  • 18
  • have you tried running the app locally? verify the your local nodejs version is the same as the one on Heroku. – Benjamin Jan 04 '20 at 14:31
  • Hi @Benjamin running my app locally works absolutely fine, it's literally just when I tried to use Heroku for it. Can I ask how I would be able to verify which ones my local is using vs Heroku? – Sunny0101 Jan 04 '20 at 14:32
  • just run "node --v" on your local command prompt, and see what version of node are you having, then check the node version in Heroku and compare them, if they are different set the Heroku node version same as your local compute. – Benjamin Jan 04 '20 at 14:35
  • You may want to have a look at this [answer](https://stackoverflow.com/a/39603895/11001213). – Ritesh Ganjewala Jan 04 '20 at 14:42

1 Answers1

1

Here is where you start:

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

Do you hardcode the port or use a default (8080)? Heroku runtime provides you with an Environment variable PORT, which is the one you should use to bind your application and accept incoming requests.

halfer
  • 19,824
  • 17
  • 99
  • 186
Beppe C
  • 11,256
  • 2
  • 19
  • 41
  • Hi Beppe, how do I not hardcode my port in order to be able to use the variable? – Sunny0101 Jan 06 '20 at 09:03
  • 1
    In Java I would do something like: String port = System.getenv("PORT"); then set/bind the port into the HTTP Listener. There must be something similar in NodeJs – Beppe C Jan 06 '20 at 09:33