I'm trying to deploy my app using Heroku. I think I've successfully deployed it, but every time I try to open my app on the browser, it says...
Application error An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details
When I enter heroku logs
, I get...
2017-07-15T14:20:37.334994+00:00 heroku[web.1]: State changed from starting to crashed
2017-07-15T14:20:38.012558+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=deucex.herokuapp.com request_id=8a0d5560-e3bb-4cc2-82c3-9258db8eacb5 fwd="98.26.96.65" dyno= connect= service= status=503 bytes= protocol=https
I know my app crashes, but I don't know why. I tried entering heroku restart
, doesn't work. I also tried looking up this problem, but without success. What should I do?
====== UPDATE =====
When I enter:
$ heroku run rake db:create
I get the following error:
FATAL: permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"dd9p7e3qfv5v6k", "username"=>"dzkwulhdubxmkt", "password"=>"e3864a3452e40eb2586d5fc2f6052dd9e85e8fd59804151c4701ae046743e4a8", "port"=>5432, "host"=>"ec2-23-23-244-83.compute-1.amazonaws.com"}
rake aborted!
PG::ConnectionBad: FATAL: permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
/app/vendor/bundle/ruby/2.3.0/gems/pg-0.20.0/lib/pg.rb:56:in `initialize'
/app/vendor/bundle/ruby/2.3.0/gems/pg-0.20.0/lib/pg.rb:56:in `new'
/app/vendor/bundle/ruby/2.3.0/gems/pg-0.20.0/lib/pg.rb:56:in `connect'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:701:in `connect'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:220:in `initialize'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:38:in `new'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:38:in `postgresql_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:759:in `new_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:803:in `checkout_new_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:782:in `try_to_checkout_new_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:743:in `acquire_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:500:in `checkout'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in `retrieve_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_handling.rb:116:in `retrieve_connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/connection_handling.rb:88:in `connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/tasks/postgresql_database_tasks.rb:10:in `connection'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/tasks/postgresql_database_tasks.rb:19:in `create'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/tasks/database_tasks.rb:117:in `create'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/tasks/database_tasks.rb:137:in `block in create_current'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/tasks/database_tasks.rb:304:in `block in each_current_configuration'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/tasks/database_tasks.rb:303:in `each'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/tasks/database_tasks.rb:303:in `each_current_configuration'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/tasks/database_tasks.rb:136:in `create_current'
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.1.1/lib/active_record/railties/databases.rake:27:in `block (2 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/cli/exec.rb:74:in `load'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/cli/exec.rb:74:in `kernel_load'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/cli/exec.rb:27:in `run'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/cli.rb:360:in `exec'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/vendor/thor/lib/thor.rb:369:in `dispatch'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/cli.rb:20:in `dispatch'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/vendor/thor/lib/thor/base.rb:444:in `start'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/cli.rb:10:in `start'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/exe/bundle:35:in `block in <top (required)>'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
/app/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.1/exe/bundle:27:in `<top (required)>'
/app/bin/bundle:3:in `load'
/app/bin/bundle:3:in `<main>'
Tasks: TOP => db:create
(See full trace by running task with --trace)
===== UPDATE ========
When I try to run:
$ rails server -b $IP -p $PORT
I get:
ActiveRecord::NoDatabaseError FATAL: database "sale_development" does not exist
This is my database.yml code
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: sale_development
test:
<<: *default
database: sale_test
production:
<<: *default
database: sale_production
username: sale
password: <%= ENV['SALE_DATABASE_PASSWORD'] %>
Obviously sale_development
DOES exist. Sale is the name of my app. Why is it saying it doesn't exist?
Gem file
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.1'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3'
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'bootstrap-sass'
gem "paperclip", "~> 5.0.0"
gem 'devise', '~> 4.3'
gem 'will_paginate', '~> 3.0'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'pg'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'pg'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'rails_12factor', group: :production
Do you create a database?
Try heroku run rake db:create
or heroku run rails db:create
and then migrate.
You get message sale_development doesn't exist because when you push to heroku it's starting your app in production and for production, you have another db.
Edited
When I look to heroku logs I find a /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:292:in require': No such file to load -- test_helper.rb (LoadError)
error.
Here already fix same error