Search code examples
ruby-on-railspostgresqlrake

Rails and PostgreSQL: Role postgres does not exist


I have installed PostgreSQL on my Mac OS Lion, and am working on a rails app. I use RVM to keep everything separate from my other Rails apps.

For some reason when I try to migrate the db for the first time rake cannot find the postgres user. I get the error

 FATAL:  role "postgres" does not exist

I have pgAdmin so I can clearly see there is a postgres user in the DB - the admin account in fact - so I'm not sure what else to do.

I read somewhere about people having issues with PostgreSQL because of which path it was installed in, but then I don't think I would have gotten that far if it couldn't find the db.


Solution

  • This message pops up, when the database user does not exist. Compare the manual here.
    Multiple local databases cannot be the explanation. Roles are valid cluster-wide. The manual again:

    Note that roles are defined at the database cluster level, and so are valid in all databases in the cluster.

    You must be ending up in another database-cluster. That would be another server running on the same machine, listening to a different port. Or, more likely, on a different machine.

    Could it be that the message comes, in fact, from the remote server?