0

I am working on a project with a friend. I cloned the application from bitbucket. Everything was fine except postgresql (v9.3.7) . It keeps giving me the following message.

psql: FATAL:  password authentication failed for user "ubuntu"
FATAL:  password authentication failed for user "ubuntu"

I have created a superuser as well as all the databases. The designated users and the list of all the databases is given below.

ubuntu=# \du
                             List of roles
 Role name |                   Attributes                   | Member of 
-----------+------------------------------------------------+-----------
 divjot    | Superuser                                      | {}
 postgres  | Superuser, Create role, Create DB, Replication | {}
 ubuntu    | Superuser, Create role, Create DB              | {}

 List of databases
      Name       |  Owner   | Encoding  | Collate | Ctype |   Access privileges   
-----------------+----------+-----------+---------+-------+-----------------------
 app_development | ubuntu   | SQL_ASCII | C       | C     | 
 app_production  | ubuntu   | SQL_ASCII | C       | C     | 
 app_test        | ubuntu   | SQL_ASCII | C       | C     | 
 postgres        | postgres | SQL_ASCII | C       | C     | 
 template0       | postgres | SQL_ASCII | C       | C     | =c/postgres          +
                 |          |           |         |       | postgres=CTc/postgres
 template1       | postgres | SQL_ASCII | C       | C     | =c/postgres          +
                 |          |           |         |       | postgres=CTc/postgres
 ubuntu          | ubuntu   | SQL_ASCII | C       | C     | 

I have always struggled with postgresql configuration in rails. I follow the documentation completely, however, every time I try to clone application or move the code, I always run into problems. I am not sure why I am getting this error. Any help regarding this would be greatly appreciated. Thanks!!

5
  • looks like userubuntu is not allowed to log in. do check your pg_hba.conf file. Commented Mar 27, 2016 at 1:06
  • @wildplasser, what is the command to get access to the files. Commented Mar 27, 2016 at 1:16
  • What version? Part of the issue (IME) is that version matters. Commented Mar 27, 2016 at 1:46
  • @gene, I am running version psql (9.3.7) Commented Mar 27, 2016 at 1:57
  • Add database.yaml and ENV['DATABASE_URL'] ` setting, please. Commented Mar 27, 2016 at 2:21

1 Answer 1

2

Disclaimer: I'm not an expert on pgsql. But I've successfully set up pg/rails in several versions and environments. Here's what I suggest.

  • Find the pg_hba.conf file. Since you are apparently using Ubuntu, try

    cd /
    find . -name pg_hba.conf -print 2> /dev/null

This will search your whole disk, which will take a while. But eventually it will provide the path. If it produces more than one, you'll have to resolve which one is correct.

If you know where PG is installed, cd there instead of root.

Now

  • Verify the auth method for user ubuntu is password or maybe md5. Here is the relevant docs page. If you're interested only in local development, you can change password to trust. But if this is for production, that's a bad idea.

  • While logged into the pg command line, run
    ALTER USER ubuntu PASSWORD 'newpassword';
    to ensure the password is what you think it is.

  • You should post database.yaml or ENV['DATABASE_URL'] settings. In general, database.yaml needs to match precisely what pg expects.

For example:

development:
  adapter: postgresql
  encoding: unicode
  database: app_development
  pool: 5
  username: ubuntu
  password: <your password>
  allow_concurrency: true

Caveat: Don't commit production passwords to your repos or even dev passwords if you don't totally control the repo.

Sign up to request clarification or add additional context in comments.

1 Comment

It took me some time to find and edit the file. Thanks for pointing me to the right direction. Highly appreciate it, Thanks!!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.