-2

I got an error when I tried to access my database on postgresql:

sudo -i -u psquser psql psqdb

psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

I don't know what cause the problem since before that I could access it as normal.

As this problem before, I tried to reinstall postgresql by following this instrunction How to thoroughly purge and reinstall postgresql on ubuntu? [closed]. It took me lot of time since I have to to configured almost everything from scratch.

Is there an alternative better that I can solve this problem? Could I know what is the rootcause of this.

PS: I hosted this server on digital ocean.

1 Answer 1

2

Theres another thread that suggest Postgresql is not always running, check by;

sudo /etc/init.d/postgresql start
Sign up to request clarification or add additional context in comments.

4 Comments

thanks, It got rid of error message above, but when I tried access database again sudo -i -u psquser psql psqdb, I got role 'psquser' does not exist.
even I try access via default user 'postgres' psql -U postgres to alter user 'psquser' also not work, it ask for password of user 'postgres'. Thanks
Hmmm ok, you might need to check the pg_hba.conf for your psqdb setting and the postgresql logs. But wait, shouldn't you be using upper case -U psquser ?
after google around, I have changed pg_hba.cong to local all postgres ident and manually created role and privilege for user psquser. Then, I was enable access database and restore it successfully. Thanks very much for your answer, it really helped I will accept it :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.