Rails - Postgres - could not connect to server: Connection refused (PG::ConnectionBad) - ruby-on-rails

Yesterday I've install Postgres and pgAdminIII, all worked correctly, but after reload it stopped working. After rails server I've got error message:
=> Booting Thin
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1216:in `initialize': could not connect to server: Connection refused (PG::ConnectionBad)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1216:in `new'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1216:in `connect'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:324:in `initialize'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
from /home/home/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
from /home/home/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/railtie.rb:88:in `block in <class:Railtie>'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/home/Projects/mostdance/config/environment.rb:5:in `<top (required)>'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
from /home/home/Projects/mostdance/config.ru:3:in `block in <main>'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /home/home/Projects/mostdance/config.ru:in `new'
from /home/home/Projects/mostdance/config.ru:in `<main>'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/commands/server.rb:46:in `app'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/commands/server.rb:70:in `start'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/commands.rb:55:in `block in <top (required)>'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
This is my database.yml file:
development:
host: localhost
adapter: postgresql
encoding: unicode
database: mydb
pool: 5
timeout: 5000
username: postgres
password: password
min_messages: WARNING
test:
host: localhost
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: postgresql
encoding: unicode
database: mydb
pool: 5
timeout: 5000
username: postgres
password: password
host: 127.0.0.1
port: 5432
min_messages: WARNING
Also I try to run server Postgres:
su postgres /etc/init.d/postgresql start
Password:
* Starting PostgreSQL 9.1 database server * Use of uninitialized value $info{"pgdata"} in -d at /usr/bin/pg_ctlcluster line 331.
Use of uninitialized value $info{"pgdata"} in concatenation (.) or string at /usr/bin/pg_ctlcluster line 332.
Error: is not accessible or does not exist
Also I don't know why, but now rails server put this error:
=> Booting Thin
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1216:in `initialize': FATAL: Peer authentication failed for user "postgres" (PG::ConnectionBad)
Please, help me! If you need more information - write into comments and I will update my question

When I have had this issue in the past there are often a few things I can do to get it running, most of them seem simple, but I'm mighty forgetful --
sometimes I haven't actually created the DB after switching to postgres
bundle exec rake db:create
and then get all of my tables in there --
bundle exec rake db:migrate
other times I need to double check and make sure the PG gem is installed
gem install pg

If you are on Mac. then try reinstalling Postgresapp and then restarting everything. Make sure to import the database again.
If you are on Linux the reinstall Postgres and then restart everything.

Related

rescue in check_for_missing_columns': uninitialized constant ActiveRecord::NoDatabaseError (NameError)

I'm trying to run this application via cloud9.io. I'm not a programmer. Tried everything I could comprehend, but hit a dead end. I try to run the app, but it throw an error. Here is the output:
Digest::Digest is deprecated; use Digest
Auto-loading of `.env.development` will be removed in 1.0. See https://github.com/bkeepers/dotenv-deployment if you would like to continue using this feature.
=> Booting WEBrick
=> Rails 3.2.22 application starting in development on http://0.0.0.0:8080
=> Call with -d to detach
=> Ctrl-C to shutdown server
Connecting to database specified by database.yml
Exiting
/usr/local/rvm/gems/ruby-2.1.3/gems/doorkeeper-2.0.1/lib/doorkeeper/config.rb:29:in `rescue in check_for_missing_columns': uninitialized constant ActiveRecord::NoDatabaseError (NameError)
from /usr/local/rvm/gems/ruby-2.1.3/gems/doorkeeper-2.0.1/lib/doorkeeper/config.rb:21:in `check_for_missing_columns'
from /usr/local/rvm/gems/ruby-2.1.3/gems/doorkeeper-2.0.1/lib/doorkeeper/config.rb:11:in `configure'
from /home/ubuntu/workspace/config/initializers/doorkeeper.rb:6:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/engine.rb:593:in `block (2 levels) in <class:Engine>'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/engine.rb:592:in `each'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/engine.rb:592:in `block in <class:Engine>'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/initializable.rb:30:in `run'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/initializable.rb:55:in `block in run_initializers'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/initializable.rb:54:in `each'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/initializable.rb:54:in `run_initializers'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/application.rb:136:in `initialize!'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/ubuntu/workspace/config/environment.rb:5:in `<top (required)>'
from /home/ubuntu/workspace/config.ru:17:in `block in <main>'
from /usr/local/rvm/gems/ruby-2.1.3/gems/rack-1.4.7/lib/rack/builder.rb:51:in `instance_eval'
from /usr/local/rvm/gems/ruby-2.1.3/gems/rack-1.4.7/lib/rack/builder.rb:51:in `initialize'
from /home/ubuntu/workspace/config.ru:in `new'
from /home/ubuntu/workspace/config.ru:in `<main>'
from /usr/local/rvm/gems/ruby-2.1.3/gems/rack-1.4.7/lib/rack/builder.rb:40:in `eval'
from /usr/local/rvm/gems/ruby-2.1.3/gems/rack-1.4.7/lib/rack/builder.rb:40:in `parse_file'
from /usr/local/rvm/gems/ruby-2.1.3/gems/rack-1.4.7/lib/rack/server.rb:200:in `app'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/commands/server.rb:46:in `app'
from /usr/local/rvm/gems/ruby-2.1.3/gems/rack-1.4.7/lib/rack/server.rb:304:in `wrapped_app'
from /usr/local/rvm/gems/ruby-2.1.3/gems/rack-1.4.7/lib/rack/server.rb:254:in `start'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/commands/server.rb:70:in `start'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/commands.rb:55:in `block in <top (required)>'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/commands.rb:50:in `tap'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Process exited with code: 1
[K
Process exited with code: 1
Here's the contents of database.yml
development:
adapter: postgresql
encoding: utf8
database: bikereg
username: postgres
password: !q2w3e4r5t
pool: 5
test:
adapter: postgresql
database: bikereg_test
staging:
adapter: postgresql
database: bikereg_staging
production:
adapter: postgresql
database: bikereg_production
pool: 25
Any idea how to fix it?

rake db commands not working on production server

I've just set up my production server with a postgres db, change the env to production and run bundle install --deployment. I have also set up the postgres user on my server and created the necessary db.
When I run rake db:schema:load I get the following error:
$ rake db:schema:load
-- enable_extension("plpgsql")
rake aborted!
PG::ConnectionBad: FATAL: Peer authentication failed for user "Javu"
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:436:in `new_connection'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:446:in `checkout_new_connection'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:565:in `retrieve_connection'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:87:in `connection'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:646:in `connection'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:661:in `block in method_missing'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:632:in `block in say_with_time'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:632:in `say_with_time'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:652:in `method_missing'
/home/rails/db/schema.rb:17:in `block in <top (required)>'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/schema.rb:41:in `instance_eval'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/schema.rb:41:in `define'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/schema.rb:61:in `define'
/home/rails/db/schema.rb:14:in `<top (required)>'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `block in load'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:218:in `load_schema_for'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:235:in `block in load_schema_current'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:275:in `block in each_current_configuration'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:274:in `each'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:274:in `each_current_configuration'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:234:in `load_schema_current'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:244:in `block (3 levels) in <top (required)>'
Tasks: TOP => db:schema:load
(See full trace by running task with --trace)
rake db:migrate, rake db:create and rake db:drop returned similar errors.
My database.yml file looks like this:
default: &default
adapter: postgresql
encoding: unicode
pool: 5
development:
<<: *default
database: example_developement
password: ~
user: Javu
production:
<<: *default
database: example_production
user: postgres
host: localhost
test:
database: example_test
What do I have to do to fix this error and make the schema load work?
Looks like your database isn't configure to let your user access it. Take Rails out of the equation and using psql try to connect to the database using the information in your database.yml file. So something like...
psql -h localhost -U example_production
Get that working. Then Rails should be okay. You may need to tweak PostgreSQL or your database.yml so they agree on user/password/host settings.
Since the error returned suggests that you're trying to log in with the wrong user, the issue here seems to be that you aren't setting the Rails environment correctly.
Try running the command like this RAILS_ENV=production bundle exec rake db:schema:load.

Why is rails console ignoring my config/database.yml development: settings?

My database.yml file specifies a non-default database: and no explicit username:. If I use rails c and try to access anything it fails with, e.g.:
2.2.2 :001 > User.connection
ActiveRecord::NoDatabaseError: FATAL: role "scope" does not exist
If I try to explicitly connect using my :development settings I see:
2.2.2 :005 > ActiveRecord::Base.establish_connection :development
=>
#<ActiveRecord::ConnectionAdapters::ConnectionPool:...
#config={:adapter=>"postgresql", :encoding=>"unicode", :database=>"scope", :pool=>5, :timeout=>5000, :port=>5432, :username=>"scope", :password=>"...", :host=>"127.0.0.1"},
...
So it's clearly ignoring my custom database and my own username. Oddly enough, if I rename the yaml block from development: to anything else, e.g. staging:, I can connect fine with a ActiveRecord::Base.establish_connection :staging and access my models.
Anyone know what could be going on? I do not have a DATABASE_URL environment variable set, so that can't be overriding things. What else could be causing this behavior?
Here's the actual yml:
development:
adapter: postgresql
encoding: unicode
database: mydb_development
pool: 5
timeout: 5000
port: <%= ENV["BOXEN_POSTGRESQL_PORT"] || 5432 %>
And a stacktrace:
2.2.2 :002 > User.count
ActiveRecord::NoDatabaseError: FATAL: role "scope" does not exist
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:665:in `rescue in connect'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:655:in `connect'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
from /Users/me/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
from /Users/me/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
... 11 levels...
from /Users/me/.rvm/gems/ruby-2.2.2/gems/railties-4.2.3/lib/rails/commands/console.rb:9:in `start'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/railties-4.2.3/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
from /Users/me/Documents/projects/deliveries/bin/rails:8:in `<top (required)>'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in `load'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in `block in load'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in `load'
from /Users/me/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/me/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'2.2.2 :003 >
UPDATE
Using a new shell and connecting to the console seemed to magically fix things. I still don't know what originally corrupted things though...
Try This:
development:
adapter: postgresql
encoding: unicode
database: XXX_development
host: localhost
pool: 5
username: yourusername
password: yourpassword

Starting rails. postgresql_adapter.rb FATAL

Hi I am new in Ruby on Rails.
I've installed Rails and everything was working fine.
Then I changed database from SQLite to Postgre (because Heroku don't support it),did git push to Heroku.Everything was fine.
But when I restarted my local repository,it showed me this(on local repo):
user~:$ rails server
=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/usr/lib/ruby/vendor_ruby/active_record/connection_adapters/postgresql_adapter.rb:1215:in `initialize': FATAL: role "roma" does not exist (PG::ConnectionBad)
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/postgresql_adapter.rb:1215:in `new'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/postgresql_adapter.rb:1215:in `connect'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/postgresql_adapter.rb:323:in `initialize'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/postgresql_adapter.rb:27:in `new'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/postgresql_adapter.rb:27:in `postgresql_connection'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
from /usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
from /usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
from /usr/lib/ruby/vendor_ruby/active_record/railtie.rb:88:in `block in <class:Railtie>'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:30:in `instance_exec'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:30:in `run'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:55:in `block in run_initializers'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:54:in `each'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:54:in `run_initializers'
from /usr/lib/ruby/vendor_ruby/rails/application.rb:136:in `initialize!'
from /usr/lib/ruby/vendor_ruby/rails/railtie/configurable.rb:30:in `method_missing'
from /home/roma/Templates/first_app/config/environment.rb:5:in `<top (required)>'
from /home/roma/Templates/first_app/config.ru:3:in `require'
from /home/roma/Templates/first_app/config.ru:3:in `block in <main>'
from /usr/lib/ruby/vendor_ruby/rack/builder.rb:55:in `instance_eval'
from /usr/lib/ruby/vendor_ruby/rack/builder.rb:55:in `initialize'
from /home/roma/Templates/first_app/config.ru:in `new'
from /home/roma/Templates/first_app/config.ru:in `<main>'
from /usr/lib/ruby/vendor_ruby/rack/builder.rb:49:in `eval'
from /usr/lib/ruby/vendor_ruby/rack/builder.rb:49:in `new_from_string'
from /usr/lib/ruby/vendor_ruby/rack/builder.rb:40:in `parse_file'
from /usr/lib/ruby/vendor_ruby/rack/server.rb:277:in `build_app_and_options_from_config'
from /usr/lib/ruby/vendor_ruby/rack/server.rb:199:in `app'
from /usr/lib/ruby/vendor_ruby/rails/commands/server.rb:46:in `app'
from /usr/lib/ruby/vendor_ruby/rack/server.rb:314:in `wrapped_app'
from /usr/lib/ruby/vendor_ruby/rack/server.rb:250:in `start'
from /usr/lib/ruby/vendor_ruby/rails/commands/server.rb:70:in `start'
from /usr/lib/ruby/vendor_ruby/rails/commands.rb:55:in `block in <top (required)>'
from /usr/lib/ruby/vendor_ruby/rails/commands.rb:50:in `tap'
from /usr/lib/ruby/vendor_ruby/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
What can be cause of that?
Sorry for bad English.
In addition this is my database.yml file
development:
adapter: postgresql
database: my_database_development
pool: 5
timeout: 5000
test:
adapter: postgresql
database: my_database_development
pool: 5
timeout: 5000
production:
adapter: postgresql
database: my_database_development
pool: 5
timeout: 5000
Based on your error, you need to make a the user roma for your rails server to use to connect to your database. You can do this by using createuser to make your user defined in your database.yml. You may need to first do:
sudo su - postgres
createuser -P -s -e {your_machine_username}
but only if createuser throws an error with a normal createuser -P -s -e {user_defined_in_databaseyml}.
Then you can exit that user (exit will drop su) and do:
createuser -P -s -e {user_defined_in_databaseyml}
Then you should be able to rails s just fine (make sure you rake your db related tasks first).

Rails server exiting immediately after starting

I'm new to rails and I downloaded a repo from github which I'm trying to work on.
When I try to start rails s this happen, same thing happens for rails c:
=> Booting WEBrick
=> Rails 3.2.12 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/application/configuration.rb:115:in `read': No such file or directory - /Users/falk/Desktop/parkbuddy/config/database.yml (Errno::ENOENT)
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/application/configuration.rb:115:in `database_configuration'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.12/lib/active_record/railtie.rb:78:in `block (2 levels) in <class:Railtie>'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:25:in `each'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.12/lib/active_record/railtie.rb:74:in `block in <class:Railtie>'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `run'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `each'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/application.rb:136:in `initialize!'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/falk/Desktop/parkbuddy/config/environment.rb:5:in `<top (required)>'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `require'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `block in require'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `require'
from /Users/falk/Desktop/parkbuddy/config.ru:3:in `block in <main>'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /Users/falk/Desktop/parkbuddy/config.ru:in `new'
from /Users/falk/Desktop/parkbuddy/config.ru:in `<main>'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/commands/server.rb:46:in `app'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/commands/server.rb:70:in `start'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/commands.rb:55:in `block in <top (required)>'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/commands.rb:50:in `tap'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I have tried googling a solution but I can't find anything.
Your first line of errors says you don't have config/database.yml file.
create a database.yml file inside you applications config directory and
in database.yml file
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
test:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
The first line is showing you your problem:
/Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/application/configuration.rb:115:in `read': No such file or directory - /Users/falk/Desktop/parkbuddy/config/database.yml (Errno::ENOENT)
The config/database.yml file is not present in your Rails app. Check with the app's documentation to see what it suggest you do about database configuration.
I hava the same problem but with a different answer...
fabio#ubuntu:~/Desktop/teste/foo$ rails server
=> Booting WEBrick
=> Rails 4.0.0 application starting in development on localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/routing/mapper.rb:191:in `normalize_conditions!': You should not use the `match` method in your router without specifying an HTTP method. (RuntimeError)
If you want to expose your action to both GET and POST, add `via: [:get, :post]` option.
If you want to expose your action to GET, use `get` in the router:
Instead of: match "controller#action"
Do: get "controller#action"
from /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/routing/mapper.rb:67:in `initialize'
from /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/routing/mapper.rb:1438:in `new'
...

Resources