I can't connect to server. Using psql -h -U postgres -d mydb and pgAdmin, in both case:

psql: could not connect to server: Connection refused Is the server running on host "" and accepting TCP/IP connections on port 5432?

I changed the pg_hba.conf and postgresql.conf

listen_addresses = '*'

host    all             postgres               md5

When I restart the service:

2019-05-03 18:04:01 -03 [23773-1] LOG:  peer authentication is only supported on local sockets
2019-05-03 18:04:01 -03 [23773-2] CONTEXT:  line 92 of configuration file "/etc/postgresql/9.5/main/pg_hba.conf"
2019-05-03 18:04:01 -03 [23773-3] FATAL:  could not load pg_hba.conf


I already change md5 to peer.

92  host    all     all    peer
93  host    all     postgres       md5

ps -ef | grep post

thiago  3583 21771  0 09:04 pts/2    00:00:00 grep --color=auto post
root     24726  8345  0 Mai03 pts/1    00:00:00 sudo -i -u postgres
postgres 24727 24726  0 Mai03 pts/1    00:00:00 -bash
  • what is line 92 of the configuration file? – Patrick Mevzek May 4 at 1:14
  • As the error message says, you can't use "peer" with "host", only with "local". If you already changed md5 to peer, then change peer back to md5, or to some other method that works with "host". – jjanes May 4 at 1:23
  • After you restart, has the service actually come up - what's the output of ps -ef | grep post? You can always edit your own questions. Try logging in without the 127..... Can you su to the postgres user? Have you tried just logging in as yourself - i.e. no -U? Try leaving out the database as well - if you can get in at all, you might be able to \c to other databases. p.s. welcome to the forum! :-) – Vérace May 4 at 1:38
  • @PatrickMevzek I updated my question. But this line was already created, I just added 93. – ThiagoL May 4 at 11:58
  • @jjanes I used peer, md5 and trust, changed all to postgres. – ThiagoL May 4 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.