Heroku database error? Cannot Rake db:migrate - ruby-on-rails

I've been stuck on this for hours. I've been going back and forth with rollbacks and heroku has been crashing on me. The error I've been getting is Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details.
I've tried heroku pg:reset DATABASE_URL and then heroku rake db:migrate many many many times and it still prompts that error each time.
Here are my logs
2015-08-20T03:53:52.883786+00:00 heroku[run.7282]: Awaiting client
2015-08-20T03:53:52.917990+00:00 heroku[run.7282]: Starting process with command `bundle exec rake db:migrate`
2015-08-20T03:53:53.287377+00:00 heroku[run.7282]: State changed from starting to up
2015-08-20T03:53:58.412740+00:00 heroku[run.7282]: Process exited with status 0
2015-08-20T03:53:58.432909+00:00 heroku[run.7282]: State changed from up to complete
2015-08-20T03:54:04.586682+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=linkmony.herokuapp.com request_id=f90ecec2-49f5-4faa-9736-40bdeb637b5e fwd="76.103.13.109" dyno= connect= service= status=503 bytes=
2015-08-20T03:54:05.400560+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=linkmony.herokuapp.com request_id=44fb2fae-15b8-4359-bbbb-47c59b2a7d3b fwd="76.103.12.101" dyno= connect= service= status=503 bytes=

Running the following in terminal should give you more info:
$ heroku run rails console
(hat tip: ntimba20)

Related

Active Storage causing Rails app to fail on Heroku; works locally

I have a Rails app that works fine locally. It does not require any database. I am trying to deploy it using Heroku, but this is the only information I am getting in my logs as to why it's not working:
2018-09-14T17:27:28.074554+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=calendarizer.herokuapp.com request_id=4da3eec1-23dd-4d1a-ae8f-7b05086d20fc fwd="65.207.79.74" dyno= connect= service= status=503 bytes= protocol=https
2018-09-14T17:27:28.469113+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=calendarizer.herokuapp.com request_id=f079f20e-a9c1-4547-b563-3c2822b89e2d fwd="65.207.79.74" dyno= connect= service= status=503 bytes= protocol=https
My log level is set to DEBUG. No idea where else to look or how to tackle this problem.
EDIT:
I went back in the logs and I found this:
2018-09-14T17:37:19.872142+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.2.1/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `has_one_attached' for #<Class:0x00000007a055f8> (NoMethodError)
I had not heard of ActiveStorage before now, but it's not something I'm using (at least not intentionally).
Log dump:
2018-09-14T17:46:41.000000+00:00 app[api]: Build started by user username#gmail.com
2018-09-14T17:46:59.000000+00:00 app[api]: Build failed -- check your build logs
2018-09-14T17:47:09.445004+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=calendarizer.herokuapp.com request_id=6dca7f6f-3afd-4bcd-b144-f63b85994472 fwd="65.207.79.74" dyno= connect= service= status=503 bytes= protocol=https
2018-09-14T17:47:09.792706+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=calendarizer.herokuapp.com request_id=1818345c-2dfb-4a30-ada6-65ca3bbc04ea fwd="65.207.79.74" dyno= connect= service= status=503 bytes= protocol=https
2018-09-14T17:56:48.278447+00:00 app[api]: Starting process with command `bundle exec rake db:migrate` by user username#gmail.com
2018-09-14T17:56:52.733021+00:00 heroku[run.7080]: Awaiting client
2018-09-14T17:56:52.763164+00:00 heroku[run.7080]: Starting process with command `bundle exec rake db:migrate`
2018-09-14T17:56:52.907308+00:00 heroku[run.7080]: State changed from starting to up
2018-09-14T17:57:00.092474+00:00 heroku[run.7080]: Process exited with status 1
2018-09-14T17:57:00.107737+00:00 heroku[run.7080]: State changed from up to complete
2018-09-14T17:58:27.000000+00:00 app[api]: Build started by user username#gmail.com
2018-09-14T17:58:40.000000+00:00 app[api]: Build failed -- check your build logs
2018-09-14T17:59:08.348804+00:00 app[api]: Starting process with command `bundle exec rake db:migrate` by user username#gmail.com
2018-09-14T17:59:14.334567+00:00 heroku[run.7746]: State changed from starting to up
2018-09-14T17:59:14.252562+00:00 heroku[run.7746]: Awaiting client
2018-09-14T17:59:14.278462+00:00 heroku[run.7746]: Starting process with command `bundle exec rake db:migrate`
2018-09-14T17:59:22.174620+00:00 heroku[run.7746]: Process exited with status 1
2018-09-14T17:59:22.189708+00:00 heroku[run.7746]: State changed from up to complete
2018-09-14T17:59:56.283122+00:00 app[api]: Starting process with command `bundle exec rake db:migrate` by user username#gmail.com
2018-09-14T18:00:05.530380+00:00 heroku[run.7894]: State changed from starting to up
2018-09-14T18:00:05.579669+00:00 heroku[run.7894]: Awaiting client
2018-09-14T18:00:05.633999+00:00 heroku[run.7894]: Starting process with command `bundle exec rake db:migrate`
2018-09-14T18:00:20.779574+00:00 heroku[run.7894]: State changed from up to complete
2018-09-14T18:00:20.763154+00:00 heroku[run.7894]: Process exited with status 1
2018-09-14T18:01:58.718055+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=calendarizer.herokuapp.com request_id=989475e7-affc-41a2-ade6-5cf21ce746a9 fwd="65.207.79.74" dyno= connect= service= status=503 bytes= protocol=https
2018-09-14T18:01:59.041312+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=calendarizer.herokuapp.com request_id=38c77377-2758-4a31-9219-6dcb548a5b1e fwd="65.207.79.74" dyno= connect= service= status=503 bytes= protocol=https
Heroku usually wants to see some kind of database (ie pg) to run if something is going to get saved, which I believe having ActiveRecord in your app is going to imply (even if you don't intend to use it). So you have two solutions I believe. In your dev & test environment you likely have sqlite3 as your database (you can look in your gemfile), but Heroku doesn't work with sqlite3.
Option 1:
Disable ActiveRecord in your app - Following this post: Disable Active Storage in Rails 5.2
Option 2:
Add a database to your production environment for heroku, so it's happy:
- in your gemfile see if you have a production group already
group :production do
if not add it
add in the pg gem:
gem 'pg'
So you should end up with something like this in your gemfile:
group :production do
gem 'pg'
end
Then commit and push to Heroku. You may need to restart the Dynos in Heroku, and you may need to create the database files on heroku too:
heroku run rails db:create
You should be up and running now.
For me the problem was that the adapter in database.yml was sqlite3.
So I changed the production section of config/database.yml to:
production:
adapter: postgresql
encoding: unicodeubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
database: myapp_production
username: myapp
password: <%= ENV['MYAPP_DATABASE_PASSWORD'] %>

Heroku H10 error "App Crashed"

I'm trying to deploy my Ruby on Rails webbapp to Heroku. Locally it works just fine but when I try to run it through Heroku is gives me a H10 error HTTP status 503. I guess it's because of the bash: bundle: command not found. But even running heroku run bundle exec rails server -p $PORT doesn't work.
2016-04-26T11:35:09.570021+00:00 heroku[slug-compiler]: Slug compilation started
2016-04-26T11:35:09.570027+00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app
2016-04-26T11:36:34.435961+00:00 heroku[slug-compiler]: Slug compilation started
2016-04-26T11:36:34.435967+00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app
2016-04-26T11:37:06.665673+00:00 heroku[slug-compiler]: Slug compilation started
2016-04-26T11:37:06.665682+00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app
2016-04-26T11:37:20.446113+00:00 heroku[slug-compiler]: Slug compilation started
2016-04-26T11:37:20.446119+00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app
2016-04-26T11:37:26.534228+00:00 heroku[web.1]: State changed from crashed to starting
2016-04-26T11:37:32.239987+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 48566`
2016-04-26T11:37:34.485283+00:00 app[web.1]: bash: bundle: command not found
2016-04-26T11:37:35.145372+00:00 heroku[web.1]: Process exited with status 127
2016-04-26T11:37:35.160181+00:00 heroku[web.1]: State changed from crashed to starting
2016-04-26T11:37:35.157438+00:00 heroku[web.1]: State changed from starting to crashed
2016-04-26T11:37:40.225006+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 57613`
2016-04-26T11:37:41.536602+00:00 app[web.1]: bash: bundle: command not found
2016-04-26T11:37:42.254167+00:00 heroku[web.1]: Process exited with status 127
2016-04-26T11:37:42.273228+00:00 heroku[web.1]: State changed from starting to crashed
2016-04-26T11:37:43.433890+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=justarandomname-sandbox.herokuapp.com request_id=4570bf17-d1d5-46f8-a2fa-9b3903e5f7b8 fwd="78.128.33.2" dyno= connect= service= status=503 bytes=
2016-04-26T11:37:43.875014+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=justarandomname-sandbox.herokuapp.com request_id=bef38221-b815-42f0-bff9-a5af6ec9faef fwd="78.128.33.2" dyno= connect= service= status=503 bytes=
2016-04-26T11:37:43.928876+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=justarandomname-sandbox.herokuapp.com request_id=af6d1b23-6fca-4936-831a-8be720931110 fwd="78.128.33.2" dyno= connect= service= status=503 bytes=
2016-04-26T11:38:18.973552+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=justarandomname-sandbox.herokuapp.com request_id=bdcbfa80-b930-458c-9838-22d143092149 fwd="78.128.33.2" dyno= connect= service= status=503 bytes=
2016-04-26T11:38:30.012185+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=justarandomname-sandbox.herokuapp.com request_id=7e6af745-e613-448c-be0e-be6c14c4499e fwd="78.128.33.2" dyno= connect= service= status=503 bytes=
2016-04-26T11:38:31.797207+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=justarandomname-sandbox.herokuapp.com request_id=11006d32-abf4-481e-896e-3da3a9778902 fwd="78.128.33.2" dyno= connect= service= status=503 bytes=
2016-04-26T11:38:33.450964+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=justarandomname-sandbox.herokuapp.com request_id=731c163d-73dc-49d8-9334-96621b9afa99 fwd="78.128.33.2" dyno= connect= service= status=503 bytes=
2016-04-26T11:38:35.451317+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=justarandomname-sandbox.herokuapp.com request_id=1bf2c73c-cd8e-4b4a-a9c2-967934186c3f fwd="78.128.33.2" dyno= connect= service= status=503 bytes=
Additional info
Procfile:
web: bundle exec rails server -p $PORT
console: bundle exec rails console
Heroku config vars:
PATH => bin:vendor/bundle/ruby/2.0.0/bin:qr/qrencode-3.2.0:bin:/.bin:/usr/local/bin:/usr/bin:/bin
GEM_PATH => vendor/bundle/ruby/2.0.0
RACK_ENV => production
RAILS_ENV => production
Heroku buildpacks:
https://github.com/incaztech/heroku-buildpack-qrencode.git
I saw you have 3 problem in Gemfile:
You have defined gem 'therubyracer' under ruby clause in assets group, then you've redecrared it for production, and staging environments without clause. That is inconsistence.
You have redefine ruby version for production, and staging environments. That is mistake, thus heroku can't find out bundled gems including bundle executable.
Your log shows some records:
Your Gemfile lists the gem rails_12factor (>= 0) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
That is incorrect, so to fix it remove gem 'therubyracer', '0.12.1', and gem "qrencoder","~> 1.4.1" from -*production/staging_ group, gem 'rails_12factor' from production group, and then remove ruby "2.3.0" from the same group. Then issue bundle install, next bundle update isn't required, then add resulted Gemfile, and Gemfile.lock to git repo, and commit then, just after that do git push.

Rails app - working fine locally but not on heroku

I am building a simple app in Rails, everything has been working fine so far but now, after not working on it for a while, I cannot run the app in Heroku. Here are the errors I have on my logs. I would appreciate if someone could help me with these problem.
> 2016-01-07T10:25:13.640157+00:00 heroku[api]: Starting process with command `rails console` by chmorasan#gmail.com
> heroku[run.9775]: Awaiting client heroku[run.9775]: State changed from
> starting to up heroku[run.9775]: Error R13 (Attach error) -> Failed to
> a heroku[run.9775]: Process exited with status 128 heroku[run.9775]:
> State changed from up to complete heroku[run.1708]: State changed from
> starting to up
2016-01-07T09:08:52.323403+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=thecornershop.herokuapp.com request_id=469ee49d-d3a5-40bb-a6a7-f50efbfb89ef fwd="194.224.214.178" dyno= connect= service= status=503 bytes=
2016-01-07T09:08:52.788969+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=thecornershop.herokuapp.com request_id=cf2a50ed-2ef8-440a-8bc4-15be5f1f2244 fwd="194.224.214.178" dyno= connect= service= status=503 bytes=
2016-01-07T09:22:41.171885+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=thecornershop.herokuapp.com request_id=ba18bf52-9740-4e4e-b5bb-1f54dd40acb1 fwd="194.224.214.178" dyno= connect= service= status=503 bytes=
2016-01-07T09:22:41.699518+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=thecornershop.herokuapp.com request_id=babe9b0d-e6f5-4e0f-8d76-35a7217165eb fwd="194.224.214.178" dyno= connect= service= status=503 bytes=
I finally found the problem, it was somethings that I forgot to erase in a earlier mistake I did migrating, I just forgot to look in the actual db migrate. Thanks for the help.
I am not sure that which command you are trying to run on heroku, however, your log says:
heroku[run.9775]: Awaiting client heroku[run.9775]: State changed from starting to up heroku[run.9775]: Error R13 (Attach error)
Try to detach your command from terminal. Run it in the "background"
heroku run:detached <YOUR_COMMAND>
EDIT:
As you are trying to migrate your migration files:
heroku run:detached rake db:migrate

H10 error, desc="App crashed" showing "Application Error" on the heroku page

I am trying to deploy my application from my desktop to heroku. But shoiwng application error on the page. Here is the display of heroku logs :
2015-05-17T14:23:16.824327+00:00 app[web.1]: Exiting
2015-05-17T14:23:16.796436+00:00 app[web.1]: from bin/rails:8:in `<main>'
2015-05-17T14:23:16.796435+00:00 app[web.1]: from bin/rails:8:in `require'
2015-05-17T14:23:17.773437+00:00 heroku[web.1]: State changed from starting to crashed
2015-05-17T14:23:17.760552+00:00 heroku[web.1]: Process exited with status 1
2015-05-17T14:23:57.689913+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pacific-beach-3105.herokuapp.com request_id=85de2fe6-d894-4f53-a995-1285be93c58d fwd="203.110.246.22" dyno= connect= service= status=503 bytes=
2015-05-17T14:23:59.999420+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=pacific-beach-3105.herokuapp.com request_id=7384ee1f-1efc-4801-9a4a-a34a0d17f8fb fwd="203.110.246.22" dyno= connect= service= status=503 bytes=
2015-05-17T14:24:01.833524+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=pacific-beach-3105.herokuapp.com request_id=934a68f4-84e5-4259-9455-52d8f8602c06 fwd="203.110.246.22" dyno= connect= service= status=503 bytes=
2015-05-17T14:24:31.083965+00:00 heroku[api]: Starting process with command `bundle exec rake db:migrate` by sameerrrana#gmail.com
2015-05-17T14:24:34.043331+00:00 heroku[run.6109]: Starting process with command `bundle exec rake db:migrate`
2015-05-17T14:24:34.759590+00:00 heroku[run.6109]: State changed from starting to up
2015-05-17T14:24:38.220213+00:00 app[run.6109]: ActiveRecord::SchemaMigration Load (1.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
2015-05-17T14:24:38.954062+00:00 heroku[run.6109]: State changed from up to complete
2015-05-17T14:24:38.944714+00:00 heroku[run.6109]: Process exited with status 0
2015-05-17T14:25:11.918187+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pacific-beach-3105.herokuapp.com request_id=d5969403-490c-4da1-aa01-905bfd39b9a1 fwd="203.110.246.22" dyno= connect= service= status=503 bytes=
2015-05-17T14:34:31.213525+00:00 heroku[api]: Starting process with command `rails console` by sameerrrana#gmail.com
2015-05-17T14:34:35.566430+00:00 heroku[run.6202]: Awaiting client
2015-05-17T14:34:35.900197+00:00 heroku[run.6202]: State changed from starting to up
2015-05-17T14:35:05.572297+00:00 heroku[run.6202]: Error R13 (Attach error) -> Failed to attach to process
2015-05-17T14:35:07.029088+00:00 heroku[run.6202]: Process exited with status 128
2015-05-17T14:35:07.045904+00:00 heroku[run.6202]: State changed from up to complete
2015-05-17T14:40:45.980758+00:00 heroku[api]: Starting process with command `bundle exec rake db:migrate` by sameerrrana#gmail.com
2015-05-17T14:40:50.488405+00:00 heroku[run.7608]: Starting process with command `bundle exec rake db:migrate`
2015-05-17T14:40:51.155554+00:00 heroku[run.7608]: State changed from starting to up
2015-05-17T14:40:56.358175+00:00 app[run.7608]: ActiveRecord::SchemaMigration Load (2.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
2015-05-17T14:40:57.410610+00:00 heroku[run.7608]: State changed from up to complete
2015-05-17T14:40:57.396701+00:00 heroku[run.7608]: Process exited with status 0
2015-05-17T14:41:11.499509+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pacific-beach-3105.herokuapp.com request_id=ddc2f1be-2fb0-43d6-a24d-00e9a6631be0 fwd="203.110.246.22" dyno= connect= service= status=503 bytes=
I have been to every question regarding Application error and Error H10 but can't solve it . Please help
Add this line in the Gemfile.
gem 'pg', group: :production
then
bundle install
and commit the changes to the github. And then run the command
git push heroku master

heroku run rake db:migrate error for rails and mysql project

i have a project with rails 4.2 and mysql database. but when i do heroku run rake db:migrate result is:
Running `rake db:migrate` attached to terminal... up, run.1461
/usr/bin/env: ruby2.2: No such file or directory
and i don't have bin in my .gitignore.
in my heroku logs i have two errors:
heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=serene-ocean-1351.herokuapp.com request_id=a40f485d-e55e-4246-b863-a8b13a3b89fa fwd="199.189.106.136" dyno= connect= service= status=503 bytes=
heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=serene-ocean-1351.herokuapp.com request_id=3404e956-71db-4530-be1f-ce6f3f23a857 fwd="199.189.106.136" dyno= connect= service= status=503 bytes=
Look up files in the bin directory of the project, in the first line will be
#!/usr/bin/env ruby2.2
you have to simply change it to
#!/usr/bin/env ruby
If you have just upgraded to Rails 4 then try the following to update Heroku's binaries to support your commands.
$ heroku run rake rails:update:bin --app serene-ocean-1351

Resources