2

I just installed rails and postgresql (by following this tutorial) on a new computer and I'm trying to run a rails app that had been previously made and is working and in production. However, once I tried running the app, I received this error:

 /home/andrew/.rvm/gems/ruby-2.1.2/gems/activerecord-3.2.19/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `initialize': FATAL:  password authentication failed for user "rooms" (PG::ConnectionBad)
FATAL:  password authentication failed for user "rooms"
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activerecord-3.2.19/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `new'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activerecord-3.2.19/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `connect'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activerecord-3.2.19/lib/active_record/connection_adapters/postgresql_adapter.rb:324:in `initialize'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activerecord-3.2.19/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activerecord-3.2.19/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
    from /home/andrew/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
    from /home/andrew/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activerecord-3.2.19/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activerecord-3.2.19/lib/active_record/model_schema.rb:310:in `clear_cache!'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activerecord-3.2.19/lib/active_record/railtie.rb:103:in `block (2 levels) in <class:Railtie>'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:418:in `_run__3258742772582479979__prepare__847046652929319931__callbacks'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:405:in `__run_callback'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activesupport-3.2.19/lib/active_support/callbacks.rb:81:in `run_callbacks'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/actionpack-3.2.19/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/actionpack-3.2.19/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/railties-3.2.19/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/railties-3.2.19/lib/rails/initializable.rb:30:in `instance_exec'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/railties-3.2.19/lib/rails/initializable.rb:30:in `run'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/railties-3.2.19/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/railties-3.2.19/lib/rails/initializable.rb:54:in `each'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/railties-3.2.19/lib/rails/initializable.rb:54:in `run_initializers'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/railties-3.2.19/lib/rails/application.rb:136:in `initialize!'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/railties-3.2.19/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /home/andrew/Documents/mywebroom/config/environment.rb:5:in `<top (required)>'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:251:in `require'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:251:in `block in require'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:251:in `require'
    from /home/andrew/Documents/mywebroom/config.ru:3:in `block in <main>'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
    from /home/andrew/Documents/mywebroom/config.ru:in `new'
    from /home/andrew/Documents/mywebroom/config.ru:in `<main>'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/railties-3.2.19/lib/rails/commands/server.rb:46:in `app'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/railties-3.2.19/lib/rails/commands/server.rb:70:in `start'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/railties-3.2.19/lib/rails/commands.rb:55:in `block in <top (required)>'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/railties-3.2.19/lib/rails/commands.rb:50:in `tap'
    from /home/andrew/.rvm/gems/ruby-2.1.2/gems/railties-3.2.19/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Here's what my database.yml file looks like:

development:
    adapter: postgresql
    encoding: unicode
    host: localhost
    database: rooms_development
    pool: 5
    username: rooms
    password: rooms

I'm still new to rails and I have no idea how to fix this - please help!

Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228
user3781239
  • 141
  • 4
  • 13
  • The password you supplied does not match the password PostgreSQL has on record for the user `rooms`. Use the correct password or reset it in PostgreSQL. – Craig Ringer Jul 21 '14 at 02:00

2 Answers2

2

That's Postgres telling you the login with password failed. The manual advises:

Messages like this indicate that you contacted the server, and it is willing to talk to you, but not until you pass the authorization method specified in the pg_hba.conf file. Check the password you are providing, or check your Kerberos or ident software if the complaint mentions one of those authentication types.

More advice there ...
Or in this related answer:

Community
  • 1
  • 1
Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228
2

I was facing same problem on Ubuntu machine so I removed it by using following steps.

From console switch to postgres user

$ sudo su - postgres

it will ask for password and by default password is postgres

After switch the user to postgres, open psql console

$ psql

so check the version of postgres if multiple versions are available

psql=# select VERSION();

PostgreSQL 9.1.13 on x86_64-unk....         # so version is 9.1

Now Open postgres user

vim /etc/postgresql/9.1/main/pg_hba.conf

9.1 is version return form upper command

and replace

local   all             postgres                                peer

to

local   all             postgres                                md5

I write steps on my blog also

http://tarungarg402.blogspot.in/2014/10/set-up-postgresql-on-ubuntu.html

Tarun Garg
  • 717
  • 6
  • 19