1

Postgres 10 installed on a Ubuntu 18.04 sandbox

I'm able to connect to my database just fine if I SSH into my machine with Putty. (localhost port 22 forwarding is in place in VirtualBox)

dangel@ubuntu1804nginx:~$ psql
psql (10.5 (Ubuntu 10.5-0ubuntu0.18.04))
Type "help" for help.

dangel=#

However when trying to setup a remote connection through PGAdmin or DataGrip, I'm being asked for a database username and password...

enter image description here

enter image description here

The specified database user/password combination is rejected: 
[08004] The server requested password-based authentication, but no password was provided

I've tried leaving the database and user field blank, and also populating them. Same thing.

The reason this confuses me, is that I thought by connecting via SSH, I should be using ident authentication? Thereby not needing a password? (which I don't have a password set) (I know I must be missing a simple concept, but what is it?)

EDIT: log file entry

2018-09-02 03:57:07.865 UTC [13127] dangel@dangel FATAL:  password authentication failed for user "dangel"
2018-09-02 03:57:07.865 UTC [13127] dangel@dangel DETAIL:  User "dangel" has no password assigned.
        Connection matched pg_hba.conf line 94: "host    all             all             ::1/128                 md5"
dangel
  • 7,238
  • 7
  • 48
  • 74
  • If you haven't changed your password for the root account or if you never setup an account google what the default Postgres login is for root. If it's anything like sql it would be root with no password – Kwright02 Sep 02 '18 at 03:32

1 Answers1

0

Your pg_hba demands a password for that usage, but the user doesn't have a password so it is impossible to satisfy.

Either assign the database user a password in the database (alter user dangel password 'open_sesame'; or use the \password psql command), or change line 94 of "pg_hba.conf" to be "trust" rather than "md5". Or a third option (untested), make the "Host" on the "General" tab be the empty string, rather than "localhost".

Your psql command works, because that is using a "local" entry in the pg_hba, not the "host" entry. If you want to use psql to debug this, then you need to use psql -h localhost, which will force it to go through the same pg_hba entry as the other ones do.

jjanes
  • 37,812
  • 5
  • 27
  • 34
  • for anyone looking this up....there is an awesome solution located here...https://stackoverflow.com/questions/38466190/cant-connect-to-postgresql-on-port-5432 – thefonso Sep 20 '21 at 19:44