简体   繁体   中英

Rails Capistrano deploy PG::ConnectionBad: FATAL: password authentication failed

deploy:migrating
      01 /usr/local/rvm/bin/rvm default do bundle exec rake db:migrate
      01 rake aborted!
      01 PG::ConnectionBad: FATAL:  password authentication failed for user "customuser"
...
Tasks: TOP => db:migrate

1) I can normally login to psql under customuser 2) command on server RAILS_ENV=production rake db:migrate is workling 3) database.yml :

production:
  <<: *default
  database: app_production
  host: localhost
  username: customuser
  password: mypassword

4) /etc/postgresql/10/main/pg_hba.conf :

# "local" is for Unix domain socket connections only
local   all             all                                     md5

also tried peer

I had a the same error message when attempting to deploy a Rails app with Capistrano and arrived here.

In my case, I had hardcoded a dummy password into an environment variable:

DATABASE_URL=postgresql://deploy:PASSWORD@127.0.0.1/myapp

Of course, PASSWORD should have been the actual password.

I'm leaving this here in case my stupidity helps someone else.

Solved. Needed to add gem https://github.com/capistrano-plugins/capistrano-postgresql

In deploy.rb

set :pg_without_sudo, false
set :pg_host, 'localhost'
set :pg_database, 'appname_production'
set :pg_username, 'username'
set :pg_ask_for_password, true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM