I created a superuser portal with the following command

create role portal with superuser password 'portal'


When I tried to login into postgres with portal user I am getting the following error in rails.

FATAL:  role "portal" is not permitted to log in


I can't follow what is going on.

of course I can alter user with login command to enable portal user to login. I would like to understand why super user can't login.

You didn't specify the LOGIN right:

ALTER ROLE portal WITH LOGIN;


If you use CREATE USER instead of CREATE ROLE the LOGIN right is granted automatically; otherwise you must specify it in the WITH clause of the CREATE statement.

Superusers do not inherently have the LOGIN right; a permissions check is still performed for superuser for this right. The reason for this is so that you can have a superuser role that you can SET ROLE to, but cannot be connected as directly.
