0

It's taken me two days to get this far. But I'm almost there. When I run cap deploy:cold the deployment fails with this message:

servers: ["xxx"]
    [xxx] executing command
 ** [out :: xxx] rake aborted!
 ** [out :: xxx] FATAL:  password authentication failed for user "my_app"

My database.yaml has this:

production:
  adapter: postgresql
  encoding: utf8
  database: my_app_production
  pool: 5
  host: localhost
  username: my_app
  password: secret

I'm running cap deploy under a user I created called deployer. I installed Postgres under deployer. I also created the user my_app in psql:

create user my_app with password 'secret';
create database my_app_production owner my_app;

I verified that the user my_app exists by running \du. When I ssh through deployer@xxx and I run the command psql I get psql: FATAL: role "deployer" does not exist.

What am I doing wrong?

2 Answers 2

1

For the psql invocation to be similar as what rails does, it should be:

psql -h localhost -U my_app -d my_app_production

If you omit these options, psql will take by default:

  • the OS username as the database username
  • the OS username as the database name
  • a Unix socket directory as the host (which differs from localhost and generally has different authentication rules in pg_hba.conf)
0
0

I've gone through the very same Railscasts you are going through I think. I just got my site up with it, though I am still having a couple glitches with cap deploy. In any case, for clarity.

You created a deployer user on the remote host obviously. But, that doesn't mean "deployer" is a user in Postgres. Once you ssh as [email protected] you have to run sudo -u postgres psql to enter psql as the default postgres admin. Presuming you're using Ubuntu, there is no default password.

Where I'm confused is how, if you can't get in on the remote system with deployer, did you create the my_app user in psql there? It almost sounds like you did this locally (Vagrant maybe?) and didn't do it remotely. As I said, I think I just finished the same stuff you're looking at and it works if the my_app user is created on the remote box with the correct password.

3
  • Yes, I create my_app when I was sshed into deployer. I also set a password for postgres user. Those are the only two users in the db. I think Postgresql expects that the user logging into it is the same user of the system: system user = deployer, but Rails tries to login as my_app.
    – dee
    May 17, 2013 at 12:13
  • Can you put up your deploy script? Again, I am doing the same railscasts you are and it does work. Maybe you have my_app in where you need a deployer to be or something.
    – Art
    May 17, 2013 at 14:59
  • My deploy script is identical to Railscasts. I figured it out. The password for my_app was wrong. Make sure you are able to log into psql as my_user: psql -h localhost -U my_app -d my_app_production it will ask you for the password. Take a look at this gist, it has all the instructions: gist.github.com/abitdodgy/5600034
    – dee
    May 17, 2013 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.