FATAL: Peer authentication error for custom "rails"

I am trying to run rake db:create with postgresql on a DigitalOcean server.

However, it returns a Peer authentication failed for user "rails" error, citing config/database.yml , where login credentials are stored

What is strange is that these are the exact credentials displayed to me in plain text when entering the server through SSH. I tried both <%= ENV['APP_DATABASE_PASSWORD'] %> and the password displayed to me in text form, and the same thing happens.

The environment is in production, which I have to force manually, because the application is under development at startup and the forced change in config/environments.rb does not work.

If I had to guess, I could say that something funny is happening to the environment, because DigitalOcean will continue to maintain the cached version of the site until the server restarts and, perhaps, But I'm in trick-22 until I find out how to make it run at startup.

This question is what I came to after a lot of trouble with postgres and trying to create a database on the backend, so I need to go through a couple of things.

Thank you very much.

+5
source share
1 answer

The problem is your pg_hba.conf . Which can be found in /etc/postgresql/9.3/main/pg_hba.conf . Here 9.3 is the version of postgres that you can change with your version of postgres. More authentication information here .

You have code similar to:

 # TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all peer 

You can either change it to md5 or trust .

 # TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all trust 

It will fix your problem.

Note. To edit the pg_hba.conf , you must have sudo permission on the server.

+13
source

Source: https://habr.com/ru/post/1236944/


All Articles