Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PG::ConnectionBad FATAL: role "myapp" does not exist

I'm able to type rails s without any issues inside of an app using postgres.app on Mac using postgres.app, however, when I go to localhost:3000 it gives me this error:

PG::ConnectionBad
FATAL: role "myapp" does not exist

I thought at first the problem was the database.yml file but heroku docs even say to have it the way it is: https://devcenter.heroku.com/articles/getting-started-with-rails4

development:
adapter: postgresql
encoding: unicode
database: myapp_development
pool: 5
username: myapp
password:

Here is my full log. I've seen similar issues but they only vaguely relate to this.

snippet:

Started GET "/" for 127.0.0.1 at 2014-03-25 16:48:31 -0600

PG::ConnectionBad (FATAL:  role "myapp" does not exist
):
  activerecord (4.0.2) lib/active_record/connection_adapters/postgresql_adapter.rb:831:in `initialize'
  activerecord (4.0.2) lib/active_record/connection_adapters/postgresql_adapter.rb:831:in `new'
  activerecord (4.0.2) lib/active_record/connection_adapters/postgresql_adapter.rb:831:in `connect'
  activerecord (4.0.2) lib/active_record/connection_adapters/postgresql_adapter.rb:548:in `initialize'
  activerecord (4.0.2) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
  activerecord (4.0.2) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
  activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:440:in `new_connection'
  activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:450:in `checkout_new_connection'
  activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in `acquire_connection'
  activerecord (4.0.2)  lib/active_record/connection_adapters/abstract/connection_pool.rb:356:in `block in checkout'
  /Users/johncurry/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
  activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `checkout'
  activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
  /Users/johncurry/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
  activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
  activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in 

any suggestions?

like image 992
user3138341 Avatar asked Mar 25 '14 22:03

user3138341


1 Answers

It would appear that you have not created a user account for the application. In psql:

CREATE USER myapp WITH PASSWORD 'thepassword';

You'll also need to create a DB if you haven't:

CREATE DATABASE myapp_development OWNER myapp;
like image 176
Craig Ringer Avatar answered Sep 22 '22 01:09

Craig Ringer