0

I deployed my mern stack app on heroku but am getting erros which I dont know what is the cause. error log

 2020-04-22T15:25:46.000000+00:00 app[api]: Build succeeded
 2020-04-22T15:25:58.707869+00:00 app[web.1]: 
 2020-04-22T15:25:58.707896+00:00 app[web.1]: > contactkeeper@1.0.0 start /app
 2020-04-22T15:25:58.707897+00:00 app[web.1]: > node server.js
 2020-04-22T15:25:58.707897+00:00 app[web.1]: 
 2020-04-22T15:25:59.586133+00:00 app[web.1]: Server started on port 5000..
2020- 04-22T15:25:59.792525+00:00 app[web.1]: Database connected...
2020-04-22T15:26:56.331376+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-22T15:26:56.334688+00:00 heroku[web.1]: State changed from crashed to starting
2020-04-22T15:27:07.526858+00:00 app[web.1]: 
2020-04-22T15:27:07.526882+00:00 app[web.1]: > contactkeeper@1.0.0 start /app
2020-04-22T15:27:07.526883+00:00 app[web.1]: > node server.js
2020-04-22T15:27:07.526883+00:00 app[web.1]: 
2020-04-22T15:27:08.176741+00:00 app[web.1]: Server started on port 5000..
2020-04-22T15:27:08.300897+00:00 app[web.1]: Database connected...
2020-04-22T15:28:05.725653+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-22T15:28:08.166135+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=quiet-stream-92502.herokuapp.com request_id=e53971ab-65b3-4aa5-bf96-678ab2e6101b fwd="105.112.99.16" dyno= connect= service= status=503 bytes= protocol=https
2020-04-22T15:28:09.099701+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=quiet-stream-92502.herokuapp.com request_id=a0b04322-cb79-472b-8c93-19c55d3e0f1b fwd="105.112.99.16" dyno= connect= service= status=503 bytes= protocol=https
digitcores
  • 293
  • 1
  • 3
  • 7

2 Answers2

0

Duplicate
Found Answer

in addition, for understanding
From Heroku's documentation : The Common Runtime provides strong isolation by firewalling all dynos off from one another. The only traffic that can reach a dyno is web requests forwarded from the router to web processes listening on the port number specified in the $PORT environment variable. Worker and one-off dynos cannot receive inbound requests.
[...]

dynos common-runtime-networking

This means that you cannot set a custom PORT.
You have to use the dynamically generated environment variable named "PORT"

Behelit
  • 53
  • 1
  • 7
0

If you look at your error carefully, you will notice that it saids running on port 5000. That reason you are getting an error is because you are not using the port number that Heroku assign to your application.

Since you are using the express, your app.listen should look like this

const PORT = process.env.PORT || 5000;

app.listen(PORT, () => {
  console.log("server has started");
});

Make sure you don't put 5000 before process.env.PORT. That would result in an error when you try to deploy to heroku.

ousecTic
  • 1,895
  • 11
  • 20