0

Ever since I installed pgAdmin 4, I've been getting issues with Rails projects. Just like this one:

FATAL:  permission denied for database "postgres"
DETAIL:  User does not have CONNECT privilege.
Couldn't create 'db_name' database. Please check your configuration.
rails aborted!
ActiveRecord::NoDatabaseError: FATAL:  permission denied for database "postgres"
DETAIL:  User does not have CONNECT privilege.

The steps I've done to fix the issues are:

GRANT CONNECT ON DATABASE db_name TO user_name;


GRANT ALL PRIVILEGES ON DATABASE db_name TO user_name;

But I still am getting the error above every time I run rails db:setup. What's happening?

2 Answers2

1

Do you already try with give permisison to the schema also?

GRANT USAGE ON SCHEMA schemaname TO username;

I got from this link if you want to learn further.

-1

FATAL: permission denied for database "postgres"

GRANT CONNECT ON DATABASE db_name TO user_name;

You need to GRANT CONNECT to the database you are trying to connect to. Based on the error message, that would be "postgres", not "db_name".

Or change the config so you don't try to connect to "postgres" in the first place.

Community
  • 1
  • 1
jjanes
  • 37,812
  • 5
  • 27
  • 34