I am trying to host an api using Heroku (using this tutorial) but it keeps crashing when I upload it on heroku. I could not POST GET PATCH or anything using the api too.
Here are the logs:
2019-09-30T01:07:09+00:00 app[api]: Build succeeded
2019-09-30T01:07:11.087893+00:00 heroku[web.1]: Starting process with command `node index.js`
2019-09-30T01:07:14.671296+00:00 heroku[web.1]: source=web.1 dyno=heroku.147978494.47f1afa0-64a4-42ab-a289-4e26dbfb7138 sample#memory_total=28.04MB sample#memory_rss=28.04MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=8074pages sample#memory_pgpgout=895pages sample#memory_quota=512.00MB
2019-09-30T01:07:14.456882+00:00 app[web.1]: MongoDB connection with retry
2019-09-30T01:07:14.69389+00:00 app[web.1]: app listening at port 3600
2019-09-30T01:07:14.741028+00:00 app[web.1]: (node:4) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
2019-09-30T01:07:16.534632+00:00 app[web.1]: MongoDB is connected
2019-09-30T01:07:37.004919+00:00 heroku[web.1]: source=web.1 dyno=heroku.147978494.47f1afa0-64a4-42ab-a289-4e26dbfb7138 sample#memory_total=28.86MB sample#memory_rss=28.86MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=8284pages sample#memory_pgpgout=895pages sample#memory_quota=512.00MB
2019-09-30T01:07:57.936203+00:00 heroku[web.1]: source=web.1 dyno=heroku.147978494.47f1afa0-64a4-42ab-a289-4e26dbfb7138 sample#load_avg_1m=0.49
2019-09-30T01:07:57.966933+00:00 heroku[web.1]: source=web.1 dyno=heroku.147978494.47f1afa0-64a4-42ab-a289-4e26dbfb7138 sample#memory_total=22.18MB sample#memory_rss=22.18MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=9600pages sample#memory_pgpgout=3923pages sample#memory_quota=512.00MB
2019-09-30T01:08:11.321679+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2019-09-30T01:08:11.348573+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-09-30T01:08:11.46165+00:00 heroku[web.1]: Process exited with status 137
2019-09-30T01:08:11.523496+00:00 heroku[web.1]: State changed from starting to crashed
2019-09-30T01:08:12.977371+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/users" host=castor-api-test-1.herokuapp.com request_id=b11ce11c-7934-4ee5-a9a3-cb9d70c68394 fwd="175.136.22.227" dyno= connect= service= status=503 bytes= protocol=https
2019-09-30T01:09:32.635588+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/users" host=castor-api-test-1.herokuapp.com request_id=3fb433e2-13d9-4e1f-ab66-f93dd9ca86ae fwd="175.136.22.227" dyno= connect= service= status=503 bytes= protocol=https
What does that mean? Thanks in advance.
there are 2 logs lines here that are the likely cause, firstly:
2019-09-30T01:08:11.321679+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
which is the error raised by the Heroku Platform. This means your app is wither not booting quick enough, or you're not binding to the correct port. Looking further back in your logs:
2019-09-30T01:07:14.69389+00:00 app[web.1]: app listening at port 3600
suggests you app is binding to port 3600. Heroku requires apps to bind to the port number provided by the PORT
environment variable, which is usually much higher than 3600, so it looks like your binding to the default port for your web apps server, which means the Heroku Runtime can't detect if your app is running and ready to receive requests. For nodejs servers, this typically requires ensuring you're using app.listen(process.env.PORT)
in your servers boot configuration