code=H10 desc="App crashed" can't find solution why it happened - node.js

So I deployed my third app to heroku but to my surprise the app is not working, it's the first time when I get this kind of error:
code=H10 desc="App crashed"
At first I forgot to set my port variable like this: const port = process.env.PORT || 5000;
And then listen to it like this:
server.listen(port, () => {
console.log('Server is runing on port 5000');
});
But even when I set up port variable I still get the same error and I don't know what can cause this error.
2018-10-04T15:12:29.405064+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=m-o-d.herokuapp.com request_id=430f142b-4820-410b-865b-cc6bffae2fa5 fwd="195.12.167.97" dyno= connect= service= status=503 bytes= protocol=https
2018-10-04T15:12:29.654458+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=m-o-d.herokuapp.com request_id=30ff6c29-f7c3-4350-aaff-4bc22f823dd8 fwd="195.12.167.97" dyno= connect= service= status=503 bytes= protocol=https
App works when I run it in my localhost like this: npm start
2018-10-04T17:09:24.933184+00:00 app[web.1]: npm ERR! Failed at the mystery_of_dungeons#1.0.0 start script.
2018-10-04T17:09:24.921760+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:542:15)
2018-10-04T17:09:24.921763+00:00 app[web.1]: at require (internal/module.js:11:18)
2018-10-04T17:09:24.921766+00:00 app[web.1]: at Module._compile (module.js:641:30)

Related

Application error at heroku first deployment

I am trying to deploy the react.js project on Heroku first time but I faced an Application error after my deployment
here are the complete Heroku logs which I got in CLI
but I can't figure it out kindly have a look at it and help me to fix it
2022-03-27T21:38:28.785305+00:00 app[web.1]: errno: -2,
2022-03-27T21:38:28.785305+00:00 app[web.1]: code: 'ENOENT',
2022-03-27T21:38:28.785305+00:00 app[web.1]: syscall: 'spawn xdg-open',
2022-03-27T21:38:28.785306+00:00 app[web.1]: path: 'xdg-open',
2022-03-27T21:38:28.785306+00:00 app[web.1]: spawnargs: [ 'http://localhost:5473' ]
2022-03-27T21:38:28.785306+00:00 app[web.1]: }
2022-03-27T21:38:28.952616+00:00 heroku[web.1]: Process exited with status 1
2022-03-27T21:38:29.035319+00:00 heroku[web.1]: State changed from up to crashed
2022-03-27T21:38:30.362490+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=prashantkr006-portfolio.herokuapp.com request_id=32017955-d828-4cb3-83bb-5549ef9b708d fwd="124.253.43.194" dyno= connect= service= status=503 bytes= protocol=https
2022-03-27T21:38:30.929163+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=prashantkr006-portfolio.herokuapp.com request_id=536688a3-05d6-4ae5-8e71-9a7416288a7c fwd="124.253.43.194" dyno= connect= service= status=503 bytes= protocol=https
2022-03-27T21:38:34.193164+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=prashantkr006-portfolio.herokuapp.com request_id=63109b08-cfb0-46c3-b456-49cfffcb4b2c fwd="124.253.43.194" dyno= connect= service= status=503 bytes= protocol=https
2022-03-27T21:38:34.734662+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=prashantkr006-portfolio.herokuapp.com request_id=f1db7ca5-c99c-4048-a461-ac45a649d965 fwd="124.253.43.194" dyno= connect= service= status=503 bytes= protocol=https
2022-03-27T21:38:36.322456+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=prashantkr006-portfolio.herokuapp.com request_id=1fe2ea64-25aa-4424-aa92-b314327af931 fwd="124.253.43.194" dyno= connect= service= status=503 bytes= protocol=https
2022-03-27T21:38:36.933721+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=prashantkr006-portfolio.herokuapp.com request_id=d5e392cd-1ccd-42b7-aa11-074c69da34b4 fwd="124.253.43.194" dyno= connect= service= status=503 bytes= protocol=https
2022-03-27T21:38:37.425993+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=prashantkr006-portfolio.herokuapp.com request_id=dbdd86bd-4a02-485e-9032-6df69426502a fwd="124.253.43.194" dyno= connect= service= status=503 bytes= protocol=https
2022-03-27T21:50:02.264561+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=prashantkr006-portfolio.herokuapp.com request_id=53022457-3a00-423f-ae40-37e33e685d23 fwd="124.253.43.194" dyno= connect= service= status=503 bytes= protocol=https
2022-03-27T21:50:02.898755+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=prashantkr006-portfolio.herokuapp.com request_id=536c5ee9-ec09-4360-8821-c8248db464a5 fwd="124.253.43.194" dyno= connect= service= status=503 bytes= protocol=https
2022-03-27T21:52:42.850643+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=prashantkr006-portfolio.herokuapp.com request_id=99a80e06-a2e5-4ae7-800a-a945e3c58ff2 fwd="124.253.43.194" dyno= connect= service= status=503 bytes= protocol=https
2022-03-27T21:52:43.403302+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=prashantkr006-portfolio.herokuapp.com request_id=c830cdd8-66ca-446b-a6cb-ad8308759ffe fwd="124.253.43.194" dyno= connect= service= status=503 bytes= protocol=https```
how to fix it?
From what I understand, your issue is similar to this one :
have an error when deploy react app in heroku
By the way, if this concerns a react.js app you should edit your post tags, you put node.js instead of react.js

Heroku app deploy failed due to unknown reason

I have been trying to deploy an app to Heroku
it has been deployed but says application error
LOGS:-
2020-10-06T04:14:51.490040+00:00 heroku[web.1]: Starting process with command `gunicorn great-usernames:wsgi`
2020-10-06T04:14:53.853073+00:00 app[web.1]: bash: gunicorn: command not found
2020-10-06T04:14:53.889337+00:00 heroku[web.1]: Process exited with status 127
2020-10-06T04:14:53.928653+00:00 heroku[web.1]: State changed from starting to crashed
2020-10-06T04:15:00.441714+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=gg-usernames.herokuapp.com request_id=508d3db8-7a0b-4469-b22c-124117a6ffa9 fwd="49.37.6.95" dyno= connect= service= status=502 bytes= protocol=https
2020-10-06T04:15:00.982496+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=gg-usernames.herokuapp.com request_id=d644c379-098b-4b37-927b-2578ca65537b fwd="49.37.6.95" dyno= connect= service= status=502 bytes= protocol=https
2020-10-06T04:15:14.860562+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=gg-usernames.herokuapp.com request_id=d2de73e7-9a89-453b-9e5f-0942f22e3ee6 fwd="49.37.6.95" dyno= connect= service= status=502 bytes= protocol=https
2020-10-06T04:15:15.333167+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=gg-usernames.herokuapp.com request_id=43020ef1-b277-40a7-8555-2b71418f1917 fwd="49.37.6.95" dyno= connect= service= status=502 bytes= protocol=https
2020-10-06T04:16:38.957562+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=gg-usernames.herokuapp.com request_id=97723735-ca99-4b00-818d-c36ac77867d6 fwd="49.37.6.95" dyno= connect= service= status=503 bytes= protocol=https
2020-10-06T04:16:39.649714+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=gg-usernames.herokuapp.com request_id=ca46ab12-0bf2-4e71-b3d5-f6760fd040d1 fwd="49.37.6.95" dyno= connect= service= status=503 bytes= protocol=https
2020-10-06T04:21:08.498502+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=gg-usernames.herokuapp.com request_id=0a99c7bf-2a90-4bba-bbf1-46fc85bd3cc7 fwd="49.37.6.95" dyno= connect= service= status=503 bytes= protocol=https
2020-10-06T04:21:09.153869+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=gg-usernames.herokuapp.com request_id=ed12acab-3296-4a09-b7fe-7b1f8fbcb25f fwd="49.37.6.95" dyno= connect= service= status=503 bytes= protocol=https
thanks in advance
Specify gunicorn and version in the requirements.txt
gunicorn==20.0.4

Application error when deploying website to Heroku

My first time deploying the website I got a long error as shown below.
2020-09-25T07:31:36.727714+00:00 heroku[web.1]: State changed from starting to crashed
2020-09-25T07:31:36.730015+00:00 heroku[web.1]: State changed from crashed to starting
2020-09-25T07:31:40.230036+00:00 heroku[web.1]: Starting process with command `node server.js`
2020-09-25T07:31:43.021415+00:00 heroku[web.1]: Process exited with status 1
2020-09-25T07:31:43.061920+00:00 heroku[web.1]: State changed from starting to crashed
2020-09-25T07:31:44.106774+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=secure-coast-24568.herokuapp.com request_id=3ba32d6b-e60d-4566-8a67-bf06d6957146 fwd="116.88.43.115" dyno= connect= service= status=503 bytes= protocol=https
2020-09-25T07:31:44.535220+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=secure-coast-24568.herokuapp.com request_id=2e8669b0-19cb-43aa-90c8-1e1770aa3e6a fwd="116.88.43.115" dyno= connect= service= status=503 bytes= protocol=https
2020-09-25T07:36:38.651280+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=secure-coast-24568.herokuapp.com request_id=0d39c46b-d0d8-4bfb-9516-1c8fae89dce6 fwd="116.88.43.115" dyno= connect= service= status=503 bytes= protocol=https
2020-09-25T07:36:39.102621+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=secure-coast-24568.herokuapp.com request_id=9b23f6b1-e2ec-4f12-8b25-cb000a229675 fwd="116.88.43.115" dyno= connect= service= status=503 bytes= protocol=https
2020-09-25T07:48:16.835509+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=secure-coast-24568.herokuapp.com request_id=956d30e4-a981-48fd-9ec9-2598975d3e1d fwd="116.88.43.115" dyno= connect= service= status=503 bytes= protocol=https
2020-09-25T07:48:17.345353+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=secure-coast-24568.herokuapp.com request_id=35947874-9055-4b74-ab76-31c4329e0c72 fwd="116.88.43.115" dyno= connect= service= status=503 bytes= protocol=https
I am not sure what is the cause of the problem but there were many others too getting the same errors which was rectified. Going through what they did to fix the problem I followed the steps but still got the same error. Currently the website is working 100% when used locally and I did multiple tests before I deployed it.
This is my server.js
const dotenv = require("dotenv");
const mongoose = require("mongoose");
const app = require("./app");
app.set("view engine", "ejs");
process.on("uncaughtException", () => {
process.exit(1);
});
dotenv.config({
path: "./config.env",
});
const DB = process.env.DATABASE.replace(
"<PASSWORD>",
process.env.DATABASE_PASSWORD
);
mongoose
.connect(DB, {
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false,
useUnifiedTopology: true,
})
.then(() => {
console.log("Success");
});
// Server
const port = process.env.PORT || "3000";
const server = app.listen(port, () => {
console.log("Server started");
});
// Handle all the errors in the async code that wasnt handle
process.on("unhandledRejection", () => {
server.close(() => {
process.exit(1);
});
});
My environment variables, e.g. DATABASE and DATABASE_PASSWORD, are set in a file called config.env, which is ignored via my .gitignore since it contains sensitive information.
Your config.env file should indeed be ignored. Sensitive information like your database credentials shouldn't be committed.
However, your application needs those values. On Heroku, the solution is to set config vars that get exposed to your application as environment variables. You can do this with the Heroku CLI, e.g.
heroku config:set DATABASE_PASSWORD=12345
or via the web dashboard.
Note that in most cases you shouldn't be setting database credentials manually on Heroku. Use a database addon and whatever config vars it sets, e.g. the Heroku Postgres service sets a variable called DATABASE_URL automatically.

How can I fix my heroku app and prevent it from crashing? at=error code=H10 desc="App crashed" method=GET path="/"

My app has always been working well, but suddenly it started crashing when I tried pushing to heroku.
Here are the logs:
2019-07-29T10:15:28.986142+00:00 app[web.1]: npm ERR!
2019-07-29T10:15:28.990123+00:00 app[web.1]: npm ERR! Failed at the jobdirecto#1.0.0 start script.
2019-07-29T10:15:28.990128+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-07-29T10:15:29.002123+00:00 app[web.1]:
2019-07-29T10:15:29.002127+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-07-29T10:15:29.002129+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-07-29T10_15_28_987Z-debug.log
2019-07-29T10:15:29.097390+00:00 heroku[web.1]: State changed from starting to crashed
2019-07-29T10:15:29.077730+00:00 heroku[web.1]: Process exited with status 1
2019-07-29T14:10:35.913876+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vast-eyrie-16248.herokuapp.com request_id=8690ecb0-5c93-41f1-b861-1e2ecc194863 fwd="87.191.57.50" dyno= connect= service= status=503 bytes= protocol=https
2019-07-29T14:10:36.826030+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=vast-eyrie-16248.herokuapp.com request_id=df653f75-9e1f-46ab-a5ed-e867a8c95687 fwd="87.191.57.50" dyno= connect= service= status=503 bytes= protocol=https
Here is the node configuration:
if (process.env.NODE_ENV != "production") {
app.use(
"/bundle.js",
require("http-proxy-middleware")({
target: "http://localhost:8081/"
})
);
} else {
app.use("/bundle.js", (req, res) => res.sendFile(`${__dirname}/bundle.js`));
}
app.listen(process.env.PORT || 8080);
Please help me as I've been days trying to solve this and I still can't figure out a solution.

502 Bad Gateway nginx google app engine

I am building a NodeJS application using express here is my code:
var express = require('express');
var app = express();
var session = require('express-session');
var uuidv1 = require('uuid/v1');
require('dotenv').config();
var APIAI_TOKEN = process.env.APIAI_TOKEN;
var APIAI_SESSION_ID = uuidv1();
app.use(express.static(__dirname + '/views')); // html
app.use(express.static(__dirname + '/public')); // js, css, images
var server = require('http').createServer(app);
var port = process.env.port || 3000;
server.listen(port, function() {
console.log('Server listening at port: ', port);
// console.log(APIAI_SESSION_ID);
// console.log(APIAI_TOKEN);
});
app.use(session({
genid: function(req) {
return APIAI_SESSION_ID;
},
secret: 'secret',
saveUninitialized: true,
resave: true
}));
var io = require('socket.io')(server);
var apiai = require('apiai')(APIAI_TOKEN);
var rp = require('request-promise');
//#region Web UI
app.get('/', function(req, res) {
res.sendFile('index.html');
});
I start my app with node app and everything works perfectly on my localhost but when I deploy the app to Google App engine i get a 502 bad gateway error and when i check the log it happens at the app.get() method.
I even deployed it to Heroku server as well, the app is crashing at the same point. What could be wrong with my code?
Here is the log form Heroku server:
2017-11-01T16:35:57.528020+00:00 heroku[router]: at=error code=H10
desc="App crashed" method=GET path="/" host=ippcbot.herokuapp.com request_id=d956df30-8352-4a54-80e6-2aa1fc96276b fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T16:35:58.138751+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ippcbot.herokuapp.com request_id=96b2bf0d-df05-4d7e-9018-0b09e1dfa748 fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2017-11-01T16:19:36.517868+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-11-01T16:19:36.513572+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-11-01T16:19:36.517927+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2017-11-01T16:19:36.584087+00:00 heroku[web.1]: Process exited with status 1
2017-11-01T16:19:36.607609+00:00 heroku[web.1]: State changed from starting to crashed
2017-11-01T16:20:47.248202+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ippcbot.herokuapp.com request_id=41e9f39b-e908-4cee-a430-0d7f44a17590 fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T16:20:47.891459+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ippcbot.herokuapp.com request_id=9f244daf-7a3e-405e-b445-2fadd8b2735b fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T16:35:13.187594+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ippcbot.herokuapp.com request_id=455ccd5e-e389-49be-b892-e5e222c9864f fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T16:35:13.805998+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ippcbot.herokuapp.com request_id=112a5f08-632e-463d-b8e8-ed6de13b3596 fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T16:35:57.528020+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ippcbot.herokuapp.com request_id=d956df30-8352-4a54-80e6-2aa1fc96276b fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T16:35:58.138751+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ippcbot.herokuapp.com request_id=96b2bf0d-df05-4d7e-9018-0b09e1dfa748 fwd="197.210.37.211" dyno= connect= service= status=503 bytes= protocol=https
Not sure about Heroku, but for App Engine does changing the port to 8080 work?
For example:
const server = app.listen(8080, () => {
const host = server.address().address;
const port = server.address().port;
console.log(`Example app listening at http://${host}:${port}`);
});
From Run Express.js on Google App Engine Flexible Environment

Resources