Sunday, 16 April 2017

Heroku Node app keeps crashing

I have an Express app hosted on Heroku. Locally it runs just fine, but keeps crashing on Heroku. Every time I go to it I get the 'Application Error' page.

application error page

I double checked all environment variables and they seem ok.

The Heroku logs don't exactly offer much help:

2017-04-16T23:02:49.001768+00:00 heroku[web.1]: State changed from crashed 
to starting
2017-04-16T23:02:52.072906+00:00 heroku[web.1]: Starting process with 
command `npm run start`
2017-04-16T23:02:56.042611+00:00 app[web.1]: 
2017-04-16T23:02:56.042628+00:00 app[web.1]: > my-app@0.0.1 start /app
2017-04-16T23:02:56.042629+00:00 app[web.1]: > node bin/app
2017-04-16T23:02:56.042630+00:00 app[web.1]: 
2017-04-16T23:02:57.200912+00:00 heroku[web.1]: State changed from starting 
to crashed
2017-04-16T23:02:57.201454+00:00 heroku[web.1]: State changed from crashed 
to starting
2017-04-16T23:02:57.192198+00:00 heroku[web.1]: Process exited with status 0
2017-04-16T23:03:00.981528+00:00 heroku[web.1]: Starting process with 
command `npm run start`
2017-04-16T23:03:04.312475+00:00 app[web.1]: 
2017-04-16T23:03:04.312489+00:00 app[web.1]: > my-app@0.0.1 start /app
2017-04-16T23:03:04.312490+00:00 app[web.1]: > node bin/app
2017-04-16T23:03:04.312491+00:00 app[web.1]: 
2017-04-16T23:03:06.093211+00:00 heroku[web.1]: Process exited with status 0
2017-04-16T23:03:06.112842+00:00 heroku[web.1]: State changed from starting 
to crashed

So then I tried starting the app manually:

$ heroku run bash
...
$ npm run start

I got no errors. I'm using the pm2 process manager, so I checked it to see if the app is running and it seems like it is:

$ node_modules/.bin/pm2 list
...

pm2 output

But then when I go to open my app I get the same 'Application error' page as before.

'heroku restart' doesn't help. It just crashes again every time.

The only difference between my local environment and Heroku (as far as I can tell at least...) is that locally I have a file from which I'm reading a RSA private key, and on Heroku that key is read from the environment.

Any ideas?



via Yulek

No comments:

Post a Comment