Reputation: 118
I am trying to host my app on heroku but everytime it is showing this I don't know what to do localhost is working fine. i have both 3000||PORT in app.js
app.listen(3000 || process.env.PORT, function() {
console.log("server started");
});
2020-04-17T09:18:25.211095+00:00 heroku[web.1]: State changed from crashed to starting
2020-04-17T09:18:25.004117+00:00 app[api]: Deploy 90cb3367 by user [email protected]
2020-04-17T09:18:25.004117+00:00 app[api]: Release v4 created by user [email protected]
2020-04-17T09:18:26.000000+00:00 app[api]: Build succeeded
2020-04-17T09:18:31.052029+00:00 app[web.1]:
2020-04-17T09:18:31.052049+00:00 app[web.1]: > [email protected] start /app
2020-04-17T09:18:31.052050+00:00 app[web.1]: > node app.js
2020-04-17T09:18:31.052050+00:00 app[web.1]:
2020-04-17T09:18:31.864027+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2020-04-17T09:18:31.864060+00:00 app[web.1]: designed for a production environment, as it will leak
2020-04-17T09:18:31.864061+00:00 app[web.1]: memory, and will not scale past a single process.
2020-04-17T09:18:31.869069+00:00 app[web.1]: server started
2020-04-17T09:18:33.093946+00:00 app[web.1]: Connected to DB
2020-04-17T09:19:28.552031+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-17T09:19:28.555871+00:00 heroku[web.1]: State changed from crashed to starting
2020-04-17T09:19:28.969225+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mininin.herokuapp.com
request_id=e42100b5-53ac-4b78-a1c7-beaae05672b0 fwd="182.68.209.14" dyno= connect= service= status=503 bytes= protocol=https
2020-04-17T09:19:33.338439+00:00 app[web.1]:
2020-04-17T09:19:33.338460+00:00 app[web.1]: > [email protected] start /app
2020-04-17T09:19:33.338460+00:00 app[web.1]: > node app.js
2020-04-17T09:19:33.338460+00:00 app[web.1]:
2020-04-17T09:19:34.184638+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2020-04-17T09:19:34.184689+00:00 app[web.1]: designed for a production environment, as it will leak
2020-04-17T09:19:34.184690+00:00 app[web.1]: memory, and will not scale past a single process.
2020-04-17T09:19:34.189167+00:00 app[web.1]: server started
2020-04-17T09:19:35.441183+00:00 app[web.1]: Connected to DB
2020-04-17T09:20:31.565214+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-17T09:20:32.881860+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=mininin.herokuapp.com
request_id=0eccf9a7-6f74-4f3e-a915-8ab22aa69582 fwd="182.68.209.14" dyno= connect= service= status=503 bytes= protocol=https
2020-04-17T09:20:33.268425+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=mininin.herokuapp.com request_id=1e49adb2-5729-4fea-957d-12c864d93207 fwd="182.68.209.14" dyno= connect= service= status=503 bytes= protocol=https
2020-04-17T09:20:34.173528+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=mininin.herokuapp.com request_id=d3a7a1a9-9d22-4b51-a4d7-58efd9b785c1 fwd="182.68.209.14" dyno= connect= service= status=503 bytes= protocol=https
Upvotes: 0
Views: 46
Reputation: 1696
Can you change your listener to something like this because I guess heroku doesn't allow you to assign listening ports but provides them dynamically. In your case 3000 || process.env.PORT
it always return PORT 3000.
app.listen(process.env.PORT || 3000, function() {
console.log("server started");
});
Upvotes: 1