Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Postgresql db:migrate when deploy #230

Open
unavailabl3 opened this issue Apr 24, 2019 · 7 comments
Open

Problem with Postgresql db:migrate when deploy #230

unavailabl3 opened this issue Apr 24, 2019 · 7 comments

Comments

@unavailabl3
Copy link

unavailabl3 commented Apr 24, 2019

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
  1. /etc/postgresql/10/main/pg_hba.conf :
# "local" is for Unix domain socket connections only
local   all             all                                     md5

also tried peer

@hiteshranaut
Copy link

you got any solution for this?

@mattbrictson
Copy link
Member

Issues like this where you encounter different behavior in capistrano vs running the same command manually on the server are often due to different environment variables being loaded in those two scenarios. Here is some more background: https://capistranorb.com/documentation/faq/why-does-something-work-in-my-ssh-session-but-not-in-capistrano/

My general suggestion is to manually run env on the server and make note of the environment variables. Then run a capistrano task like this one to see what the environment variables are when using capistrano. If there are differences this may account for the differences in behavior you are seeing.

task :print_env do
  on release_roles(:all) do
    puts capture("env")
  end
end

@hiteshranaut
Copy link

thanks for reply
I also inserted details directly into database but still getting error
PG::ConnectionBad: could not connect to server: Connection refused
01 Is the server running on host "127.0.0.1" and accepting
01 TCP/IP connections on port 5432?

@mattbrictson
Copy link
Member

Sorry, I don't have any more ideas. Let us know what you find.

@jose2007kj
Copy link

please check here there are few lines added
DATABASE_URL=postgresql://deploy:[email protected]/myapp
https://gorails.com/deploy/ubuntu/18.04

@hiteshranaut
Copy link

Thanks @jose2007kj

for me issue was there was commented database connection on top after removing that commented connect it worked for me.

@aesyondu
Copy link

Just would like to share my story. I found out the hard way that dotenv files are unable to parse the $ sign (bkeepers/dotenv#214). My temporary solution was to hardcode the password in my config file.

Also this might be helpful if you want to continue deployment without migration (https://stackoverflow.com/a/28300857). Though the app still wouldn't work without a working (database) password.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants