167

I have a RoR app working on my local computer, but when I send it to heroku, it crashes. The error log gives an error H10 & says:

    2012-11-21T15:26:47+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.4.2/lib/new_relic/control/instance_methods.rb:95:in `start_agent'
    2012-11-21T15:26:48+00:00 heroku[web.1]: State changed from starting to crashed
    2012-11-21T15:26:48+00:00 heroku[web.1]: Process exited with status 1
    2012-11-21T15:26:59+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=xxx.herokuapp.com fwd= dyno= queue= wait= connect= service= status=503 bytes=
    2012-11-21T15:27:00+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=xxx.herokuapp.com fwd= dyno= queue= wait= connect= service= status=503 bytes=
    2012-11-21T15:30:08+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=xxx.herokuapp.com fwd= dyno= queue= wait= connect= service= status=503 bytes=
    2012-11-21T15:30:08+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=xxx.herokuapp.com fwd= dyno= queue= wait= connect= service= status=503 bytes=
    2012-11-21T15:30:59+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=xxx.herokuapp.com fwd= dyno= queue= wait= connect= service= status=503 bytes=
    2012-11-21T15:31:19+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=xxx.herokuapp.com fwd= dyno= queue= wait= connect= service= status=503 bytes=
    2012-11-21T15:31:19+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=xxx.herokuapp.com fwd= dyno= queue= wait= connect= service= status=503 bytes=
    2012-11-21T15:32:08+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=xxx.herokuapp.com fwd= dyno= queue= wait= connect= service= status=503 bytes=
    2012-11-21T15:32:08+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=xxx.herokuapp.com fwd= dyno= queue= wait= connect= service= status=503 bytes=

Edit:

2012-11-22T10:00:58+00:00 app[web.1]: 
2012-11-22T10:00:59+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=xxx.herokuapp.com fwd= dyno=web.1 queue=0 wait=0ms connect=1ms service=26ms status=200 bytes=0

Has anyone had this before, and know what might be causing the problem? I cannot find a solution.

Thanks.

bskool
  • 2,068
  • 2
  • 17
  • 24
  • Have same error few months before. Just started new HEROKU app, and it helps. I t looks like you have broken dyno in dyno pool. – Rustem Nov 21 '12 at 17:05
  • Unfortunately this did not resolve my issue. – bskool Nov 21 '12 at 17:45
  • Is there anything you need to do to configure New Relic on Heroku, or perhaps in your app? (NewRelic is server and app monitoring software, so it's possible that what you're seeing is NewRelic kicking in to say "App has crashed"). Also, [here's another SO post](http://stackoverflow.com/questions/13446449/rails-heroku-deploying-for-the-first-time-failed) -- see the instructions in an answer. – Tom Harrison Nov 21 '12 at 19:53
  • Thanks for the reply tharrison. I still can't seem to move past this issue. Regarding the link you posted I'd like to point out that the Heroku gem is depreciated and have already migrated from SQLite3 to PostgreSQL. – bskool Nov 22 '12 at 10:03
  • Try this: heroku config:add BUILDPACK_URL=https://github.com/joelcogen/heroku-buildpack-rails-unicorn-nginx – ChuckJHardy Aug 29 '14 at 20:24
  • This is so annoying. Especially since it's so difficult to increase the log level to include error traces. – max pleaner Jan 19 '16 at 00:25
  • Had the same H10 error. After inspecting the logs it turned out to be a problem with `whitenoise` and so I worked out [this solution](https://stackoverflow.com/questions/41441832/django-core-exceptions-improperlyconfigured-wsgi-application-application-coul/69442753#69442753). Perhaps it helps someone here as well. – Jakob Oct 04 '21 at 22:01

37 Answers37

370

I ran into the same error above, app was crashing on heroku (running fine in dev) but error logs on heroku were not revealing any clues. I read other answers on this page and broke out in a sweat after seeing "rebuilding the app." I figured maybe I could get in the heroku console and look around. I did and even the console crashed, but this time it told me why. It was some obscure variable I forgot to delete during a troubleshooting session hours earlier. I am not saying you will run into the same problem, but I found more info when I tried to go through the console.

$ heroku run rails console
starball
  • 20,030
  • 7
  • 43
  • 238
ntimba20
  • 3,716
  • 1
  • 12
  • 4
  • 30
    This was a great answer, helped me when the heroku logs lacked details. Thanks. – Micah Jun 20 '14 at 15:32
  • 11
    Just wanted to say, I had this issue again, googled, found this answer, saw I'd upvoted it, and it solved my problem again. Thanks @user3721026. If you see this comment, please upvote the answer again because I can't :P – mraaroncruz Sep 02 '14 at 10:28
  • 7
    I had this same issue in python but stumbled across here instead. The equivalent there is "$ heroku run python manage.py shell" which immediately showed me what was wrong. – dlb8685 Nov 21 '14 at 22:39
  • 16
    `heroku restart` helped me identify my issue. My `bin` folder was missing. – Steve Jan 08 '15 at 04:51
  • 1
    when i do it, i got this error: `/usr/bin/env: ruby2.2: No such file or directory ` – Zakaria Feb 18 '15 at 22:11
  • 1
    @steve's comment of `heroku restart` fixed it. That's all it needed for me. – Diego Barros Mar 05 '16 at 07:46
  • Anyone coming to this since the pg gem upgraded to 1.0 should downgrade back to 0.21.0 until Rails supports 1.0. https://github.com/rails/rails/pull/31671 – Brett Bim Mar 05 '18 at 17:18
  • `heroku local` worked for me (runs the heroku project using the heroku cli locally) – Ronin Mar 19 '18 at 06:13
  • in case anyone is reading this going "how would running the console even help???" -- just by running it, it won't work, in turn resulting the error that is preventing the app from working – uno Jan 20 '19 at 08:45
  • this is a great tip. i've found that often i get this error when there's an issue with YML syntax. running console helps to identify the offending file. – afishintaiwan May 13 '19 at 04:40
  • this was caused by simple misspelled authenticate_user!. this helps me to troubleshoot thanks man – gsumk Sep 25 '19 at 18:41
  • Amazing! This helped me iteratively deploy and fix the errors with my app since the Heroku console lacks some major details. – Christian Gossain Apr 17 '23 at 04:40
51

I was having the same issue. Logs weren't giving me any clues either. So I scaled down and scaled back up the dynos. This solved the problem for me:

heroku ps:scale web=0

Waited a few seconds...

heroku ps:scale web=1
Hunter
  • 1,667
  • 17
  • 24
24
$heroku run rails console 

This is the best option since it will give you an error in your terminal which will be much more detailed than the 'app crashed' error in your Heroku logs.

Igor
  • 33,276
  • 14
  • 79
  • 112
EricSchulz
  • 261
  • 2
  • 6
  • 1
    This does not appear to be an answer. Just a suggestion how to enhance the question. You should use comment section for this purpose. – Kamiccolo Jun 30 '14 at 20:52
  • 4
    This is an answer, the correct one actually. But the same as above http://stackoverflow.com/a/24113266/376680 – mraaroncruz Sep 02 '14 at 10:31
  • 1
    Its the best answer because it explains what the command does v/s ntimba20 answer that lacks an explanation of what it does. – bartoindahouse May 16 '16 at 17:48
23
$ heroku restart

helped me get my dyno running again. I'm new to Heroku but glad I know now.

Mohamed El-Nakeep
  • 6,580
  • 4
  • 35
  • 39
Kyle Kwon
  • 361
  • 2
  • 5
16

this happened to me when I was listening on the wrong port

I changed my listen() to "process.env.PORT" so:

http.listen((process.env.PORT || 5000), function(){
  console.log('listening on *:5000');
});

instead of

http.listen(5000, function(){
  console.log('listening on *:5000');
});
newshorts
  • 1,057
  • 12
  • 12
10

Had same problem this evening. Not a very helpful error so I tried running in the console

heroku run rails c

it failed and gave me a much more helpful error. I had neglected to delete a method call in production. Once I fixed that, the app worked fine.

Gregory
  • 109
  • 1
  • 3
  • This did it for me! I was using a different version of Ruby locally and on Heroku, and it was resulting in a `SyntaxError`. Logs didn't give much information, but `rails c` did. – Matthew White Mar 21 '17 at 13:42
  • For me the issue was that I created a Model/Table called Mail. This worked fine on local, but caused a Job conflict on Heroku since it thought I was trying to use ActionMailer for this model. Running the heroku console gave me the verbose error that allowed me to pinpoint the root of the H10 App Crashed error – Zack Weiner Sep 06 '17 at 16:57
  • Thanks this solved my problem. I finally get the real error superclass mismatch and nothing related to favicon – Mauro Jul 25 '18 at 13:50
6

I solved this problem by pushing to Git:

git add .
git commit -am "some text"
git push

then push to Heroku:

git push heroku

then rake db:migrate on Heroku:

heroku run rake db:migrate
Wilson Canda
  • 434
  • 5
  • 19
Frank C Jones
  • 87
  • 1
  • 4
4

If you're using Node, you can try running the serve command directly in the console. In my case I'm running an angular application, so I tried with:

heroku run npm start

This showed me the exact error during the application startup.

Victor Vargas
  • 191
  • 2
  • 4
3

I managed to not include my .gitignore file -> that breaks heroku. #doh

Here is a working .gitignore file

/.bundle
/vendor/bundle/
/vendor/ruby/


db/*.sqlite3
/db/*.sqlite3-journal
/log/*
/tmp/*


**.war
*.rbc
*.sassc
.redcar/
.sass-cache
/config/config.yml
/config/database.yml
/coverage.data
/coverage/
/db/*.javadb/
/db/*.sqlite3
/doc/api/
/doc/app/
/doc/features.html
/doc/specs.html
/public/cache
/public/stylesheets/compiled
/public/system/*
/spec/tmp/*
/cache
/capybara*
/capybara-*.html
/gems
/specifications
rerun.txt
pickle-email-*.html
.zeus.sock

**.orig

.DS_Store

/nbproject/

.idea

/*.tmproj

**.swp

.env
.powenv

To create a .gitignore file, in terminal navigate to your apps directory and use the following command

touch .gitignore

Then you can open it up in a your text editor and put the above code into it.

Joe Mellin
  • 719
  • 8
  • 15
3

In my case i was using ENV variables in my app, but it was not set in heroku config.

heroku console gave proper error:

heroku console
`validate_options': Missing required arguments: aws_access_key_id, aws_secret_access_key (ArgumentError)

Then set the ENV config

heroku config:set AWS_ACCESS_KEY_ID='key'

Restart the Heroku

heroku restart

it works!!

devudilip
  • 1,270
  • 14
  • 25
2

I was getting this same H10 app crashed error in Heroku. I clicked 'restart all dynos' in the heroku interface, and problem solved.

tomb
  • 1,374
  • 1
  • 13
  • 23
  • 2
    I also had the exact same problem. Rails console didn't show any errors. No errors in the logs from the app. Tried restarting via the command line, tried scaling down to 0 and then back up. Nothing worked. The only thing that worked was logging into Heroku and clicking on "restart all dynos" in the dropdown at the top right. Thanks for your help! – Will Tew Jan 04 '18 at 19:37
2

I had H10 with Heroku and Node due to wrong name of the main code file. Edit package.json:

{

  ...

  "main": "correct_file_name.js",

  ...

  "scripts": {
    "start": "node correct_file_name.js"
  }
}

Or rename the file.

ariel
  • 15,620
  • 12
  • 61
  • 73
2

In my case the Procfile I used was breaking everything. Heroku looks for Procfile and applies its settings when launching the app - clearly the dev settings I used didn't make any sense for the prod server. I had to rename it to Procfile.dev and everything started working normally.

The Whiz of Oz
  • 6,763
  • 9
  • 48
  • 85
2

Solution Worked for me, Try running the command: :

Heroku restart

enter image description here

1

The root of the problem I was facing was due to not having a database. To resolve the problem I first exported my local database:

$ heroku addons:add heroku-postgresql:dev 
$ heroku addons:add pgbackups
$ PGPASSWORD=mypassword pg_dump -Fc --no-acl --no-owner -h localhost -U myuser mydb > mydb.dump 

Then imported it into Heroku:

$ heroku pgbackups:restore DATABASE 'http://site.tld/mydb.dump'

The variables to replace in these examples are: mypassword, myuser, mydb & http://site.tld/mydb.dump. Note that I had to upload the dump to a temporary server.

Resolving all my problems I wrote up a quick guide on how to deploy Enki to Heroku, which can be found here.

bskool
  • 2,068
  • 2
  • 17
  • 24
1

See if you get

bash: bin/rails: No such file or directory

in logs while running (heroku logs -t) command if yes then please Run

bundle exec rake rails:update

Don't overwrite your files, in the end this command will create

  create  bin
  create  bin/bundle
  create  bin/rails
  create  bin/rake

push these files to heroku and you are done.

Saqib R.
  • 2,919
  • 2
  • 26
  • 21
1

I got the same above error as "app crashed" and the heroku app logs is not showing much info related to the error msg reasons. Then I restarted the dynos in heroku and then it showed the error saying additional curly brace in one of the index.js files in my setup. The issue got fixed once it is removed and redeployed the app on heroku.

Hope this will be helpful to someone facing the same issue.

Praveen
  • 37
  • 7
1

After going through the entire list of answers I stumbled upon this website: https://status.heroku.com/ which details the current status/incidents with Heroku. Its always safe to check out for incidents before banging your head against the wall. For me, it was the attached incident report published on the above mentioned link that was causing the error.

SERVER INCIDENT UPDATE

PallavBakshi
  • 522
  • 2
  • 12
  • 21
1

I had the same problem, I did the following

heroku run rails c

It identified a syntax error and missing comma within a controller permitted params. As mentioned above the Heroku logs did not provide sufficient information to problem solve the problem.

I have not seen the application crashed message on Heroku previously.

  • In my case, there was an `uninitialized constant` error on Heroku that wasn't present locally. While I still need to resolve that, I was able to get a working deployment back out. – Steve Meisner Oct 12 '18 at 18:23
1

I traced my problem back to the Puma server as did @Ahmed Elkoussy, but I solved just by commenting the following line on the puma.rb file:

# pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }

mranderson
  • 11
  • 2
0

I encountered the same problem today. I did heroku run rake db:migrate though I migrated the model before, and the app doesn't crash.

Tu H.
  • 496
  • 6
  • 12
0

Be very cautious of copy and pasting code. Sometimes when you add a block into a file, it is formatted incorrectly and will yield an error.

I've had this problem before and got this error: unexpected tIDENTIFIER, expecting keyword_end

Matt Perejda
  • 509
  • 5
  • 14
  • copying and pasting code without understanding it is called cargo cult programming and will cause you far more problems than a bit of "formatting" – David Meister Jan 17 '16 at 12:28
0

Had same problem. for me it was error in before_action filters(because empty DB) Check your before_action filters, maybe they throw unhendled exeptions.

sphinx96
  • 21
  • 2
0

I had this problem when trying to run Rails in a subdirectory, and not in /. For example, I had Angular/Node/Gulp app running in /client and a Rails app running in /server, but both of them were in the same git repo, so I could track changes across the front end and back end. I got this error when trying to deploy them to Heroku. For anyone else having this issue, here is a custom buildpack that will allow running Rails in a subdirectory.

https://github.com/aarongray/heroku-buildpack-ruby

Aaron Gray
  • 11,283
  • 7
  • 55
  • 61
0

I had the same issue (same error on heroku, working on local machine) and I tried all the solutions listed here including heroku run rails console which ran without error messages. I tried heroku run rake db:migrate and heroku run rake db:migrate:reset a few times. None of this solved the problem. On going through some files that are used in production but not in dev environment, I found some whitespace in the puma.rb file to be the culprit. Hope this helps someone who has the same issue. Changing this made it work

  ActiveRecord::Base.establish_connection
  End

to

  ActiveRecord::Base.establish_connection
end
Rahul Madhavan
  • 304
  • 3
  • 10
0

I ran into the same issue while deploying to Heroku (app crash). Logs did not indicate what the problem could be. Heroku console displayed syntax error in the code of an extra bracket. Surprisingly, I did not have an issue on local rails while running the app and hence missed it. After correction and git push to Heroku, the app started working on Heroku!

smottt
  • 3,272
  • 11
  • 37
  • 44
0

I updated my settings from app.set('ip_address', process.env.IP || '127.0.0.1');

to

app.set('ip_address', process.env.IP || '0.0.0.0');

which i changed for Openshift hosting

Neville Dabreo
  • 309
  • 3
  • 5
0

I had the same issue when I started using Puma in heroku as per their guide page, this issue was solved when I commented the port line shown below

# port        ENV['PORT']     || 3000

So, disabling the above line in the puma.rb in the config directory solved the issue

workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5)
threads threads_count, threads_count

preload_app!

rackup      DefaultRackup
# port        ENV['PORT']     || 3000
environment ENV['RACK_ENV'] || 'production'

on_worker_boot do
  # Worker specific setup for Rails 4.1+
  # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
  ActiveRecord::Base.establish_connection
end
Ahmed Elkoussy
  • 8,162
  • 10
  • 60
  • 85
0

In my case I was performing git push heroku master when I am not on the master branch. I had to go to master branch first, merge the code with my other branch and then git pushed.

GilbertS
  • 591
  • 8
  • 12
0

I also encountered the same error. Adding a .gitignore file to my project resolved my issue.

My .gitignore file is here:

# Node build artifacts
node_modules
npm-debug.log

# Local development
*.env
*.dev
.DS_Store

# Docker
Dockerfile
docker-compose.yml

And I changed listen() function;

app.listen(5000, function() {
console.log("Server running on port 5000...");
});

I changed it to;

    const PORT = process.env.PORT || 5000

...

    app.listen(PORT, function() {
    console.log("Server running on port 5000...");
    });
alyssaeliyah
  • 2,214
  • 6
  • 33
  • 80
shrgrl
  • 87
  • 3
  • 13
0

The solution I posted on Dev and worked for most people using React:

https://medium.com/@uros.randelovic/causes-of-heroku-h10-app-crashed-error-and-how-to-solve-them-70495914d2a3?sk=1c51cf95e904f754a43a4b63a06b5503

npm install serve --s
"scripts": {
"dev": "react-scripts start",
"start": "serve -s build",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"heroku-postbuild": "npm run build"
}
Uros Randelovic
  • 425
  • 5
  • 6
0

I had same issue in my server-side application. by default browser requests server for favicon.ico. So I used serve-favicon package. this is the set up:

import favicon from "serve-favicon";
server.use(favicon(path.join(__dirname, "../assets/images/favicon.ico")));
Yilmaz
  • 35,338
  • 10
  • 157
  • 202
0

My 50 cents, I had this problem too and solved by:

  • inspect logs via UI from very begining of building process (eg. after commit, restart dynos) to see what happens before crash

  • when link modules do not include root directory of project (my problem..)

this:

const router = require('./logic/router.js') 

instead of:

const router = require('../DMS/logic/router.js') 
mudi77
  • 1
  • 1
  • 1
0

I know this question is very old. I add new answer just in case there is someone who has the same issue on Rails 3.

In my case, app started to crash on Heroku once "thin" gem was commented by accident on Gemfile.

It worked again I added back that gem.

byakugie
  • 643
  • 3
  • 14
0

In node.js a have the same problem

fix: remove PORT from .env file on project

// app.ts or app.js

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

// .env

PORT=5000 <--- comment or remove this line

HelloGello
  • 361
  • 1
  • 3
  • 11
0

I experienced this issue after upgrading from rails 6 to rails 7. It was because rails 7 uses the default image processor :vips, but I had not prepared my app to use vips, so there were problems.

Since I wanted to continue to use :mini_magick like I was in rails 6, I simply had to add this line to config/application.rb and all was well:

config.active_storage.variant_processor = :mini_magick

I got that information here


Now, how did I figure this out? Thankfully I could see the last heroku logs to figure out what a user had just done on the production application, I ran the app locally, and did the same thing locally and the server crashed, and I saw a problem involving vips in the server logs.

stevec
  • 41,291
  • 27
  • 223
  • 311
0

In my case, my app crashed because I was hard setting the PORT, instead of using the port that Heroku dynamically sets, which can be accessed with process.env.PORT

I was using this code

app.listen(PORT, () => {
  console.log("App started at port " + PORT);
});

so then I try this

app.listen(process.env.PORT || 3000, function(){
   console.log("Express server listening on port %d in %s mode", 
 this.address().port, app.settings.env);
});
Deepak Singh
  • 749
  • 4
  • 16