Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL fe_sendauth: no password supplied

I know there are thousands of questsions like this one here on SO but i've seen them all and i'm still not able to deal with my problem.

I'm doing everything using ansible so it's quite automated but, anyway, here are my files:

pg_hba.conf

local   all             all                                     trust
host    all             all             127.0.0.1/32            md5
host    all             all             ::1/128                 md5
host    all             all             10.11.12.0/24           md5

database.yml

production:
  database: my_db
  adapter: postgresql
  host: localhost
  username: deploy
  encoding: unicode
  min_messages: WARNING
  template: template0

And i have a deploy user (and postgres user without a password set) in my system created. And now, while i'm totally able to sign in to postgres from bash using psql -d my_db (on server), i'm not able to connect to the db with my rails app. Running rake db:migrateMigration gives me

PG::ConnectionBad: fe_sendauth: no password supplied

I'm quite terrible at beeing a devop and i'm fighting with that issue from the day before yesterday's morning and it's still here so if there is anyone who can help me with that, i would be be more than grateful.

like image 471
mbajur Avatar asked Dec 11 '14 09:12

mbajur


People also ask

How do I connect to PostgreSQL without a password?

Edit the pg_dba. conf file and change all local connections from md5 to trust. By doing this, you can log in to the PostgreSQL database server without using a password. The "C:\Program Files\PostgreSQL\12\data" is the data directory.

What is default password for postgres?

For most systems, the default Postgres user is postgres and a password is not required for authentication. Thus, to add a password, we must first login and connect as the postgres user.

Where PostgreSQL password are stored?

PostgreSQL database passwords are separate from operating system user passwords. The password for each database user is stored in the pg_authid system catalog. Passwords can be managed with the SQL commands CREATE ROLE and ALTER ROLE, e.g., CREATE ROLE foo WITH LOGIN PASSWORD 'secret' , or the psql command \password .


1 Answers

psql is using a local socket connection, rails is using localhost over TCP/IP. Local is trusted, localhost requires a password (using md5). You could setup a pgpass file for your rails user: http://www.postgresql.org/docs/current/static/libpq-pgpass.html

like image 91
Frank Heikens Avatar answered Oct 24 '22 07:10

Frank Heikens