2

Really struggling to get Postgres set up. I have installed it with home-brew (version 14). and installed the Postgres app through the website.

when I type the command 'psql' into my terminal it gives this error:

psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL:  role "edac" does not exist

my server is running on port 5432.

any help will be appreciated.

2 Answers 2

3

A standard installation of Postgres has peer authentication enabled in pg_hba.conf. If you start psql without parameters it looks to connect with a DB role of the same name as the current OS user - obviously "edac" in your case.

Either you create such a role in the database (and grant desired privileges to it), or you connect with a different (existing) role. In a fresh installation, at least the database role "postgres" exists, which is a superuser.

Either you log in with username and password. Or simpler, connect as OS user "postgres" to allow peer authentication with the DB role of the same name. Like:

sudo -u postgres psql

Then you may want to create a DB role named "edac" (without superuser privileges):

CREATE ROLE edac;

Or, to just do that in one step with the shell command createuser:

sudo -u postgres createuser edac

See:

Sign up to request clarification or add additional context in comments.

1 Comment

I get error unknown user postgres ... I actually the "/tmp/.s.PGSQL.5432" failed: FATAL: role "mycurrentusername" does not exist for any command for example psql postgres
2

For PostgreSQL v14+ installed via Brew on Mac OS Monterey on Intel Silicon, the following steps solved it for me:

  1. Navigate to /usr/local/opt/postgres@14/bin

-NOTE: The above path is different from a lot of older answers as it seems older versions of PostgreSQL didn't use the version number in the directory name.

  1. createuser -U postgres -s ${USER}

  2. Try psql postgres again.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.