Search code examples
postgresqlpgadminpgadmin-4

pgadmin4 unable to connect to server,FATAL: password authentication failed for user "postgres"


i tried to config postgresql to be able to connect to pgadmin4 "remotely" So i installed postgresql version 13 in the server ,and i tried to access it via my laptop.

But why do i always get an error , i just changed the password and i enter the username and password in the pgadmin4 ,it still says password authentication.

image1

this is my pghba.conf file.

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
host    all             all             0.0.0.0/0           trust
# IPv6 local connections:
host    all             all             ::1/128                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            trust
host    replication     all             ::1/128                 trust

this is my postgesql.conf file

listen_addresses = '*'
                    # comma-separated list of addresses;
                    # defaults to 'localhost'; use '*' for all
                    # (change requires restart)
port = 5434             # (change requires restart)
max_connections = 100           # (change requires restart)
#superuser_reserved_connections = 3 # (change requires restart)
#unix_socket_directories = '/var/run/postgresql, /tmp'  # comma-separated list of directories
                    # (change requires restart)
#unix_socket_group = ''         # (change requires restart)
#unix_socket_permissions = 0777     # begin with 0 to use octal notation
                    # (change requires restart)
#bonjour = off              # advertise server via Bonjour
                    # (change requires restart)
#bonjour_name = ''          # defaults to the computer name
                    # (change requires restart)

# - TCP settings -
# see "man tcp" for details

#tcp_keepalives_idle = 0        # TCP_KEEPIDLE, in seconds;
                    # 0 selects the system default
#tcp_keepalives_interval = 0        # TCP_KEEPINTVL, in seconds;
                    # 0 selects the system default
#tcp_keepalives_count = 0       # TCP_KEEPCNT;
                    # 0 selects the system default
#tcp_user_timeout = 0           # TCP_USER_TIMEOUT, in milliseconds;
                    # 0 selects the system default

# - Authentication -

#authentication_timeout = 1min      # 1s-600s
password_encryption = scram-sha-256     # md5 or scram-sha-256
#db_user_namespace = off

# GSSAPI using Kerberos
#krb_server_keyfile = 'FILE:${sysconfdir}/krb5.keytab'
#krb_caseins_users = off

and still i don't know why, maybe someone experienced the same ? or have any idea? fyi : i open the pgadmin4 application and the url going to this :http://127.0.0.1:60888/browser/

this is my pgadmin4 in browser


Solution

  • I solved it after changing in the pg_hba.conf

    from

    local   all             all                                     trust
    

    to become

    host   all             all                                     trust
    

    Now it works like a charm.. Thankyou everyone! :)