pg Admin 4 - password for "postgres" user when trying to connect to PostgreSQL 13 server

143.5k views Asked by At

I know that this question has been asked other times but I didn't find a solution to this problem!

I downloaded PostgreSQL 13 with pg Admin 4 and when I open it for the first time after installation it asks me for the master password that I was asked to set during installation, after I give the master password and this gets accepted I try to connect to the default server created during the installation: "PostgreSQL 13".

At this point, it asks me for a password for the user "postgres" that I don't know where to find. Specifically, it says: Please enter the password for the user 'postgres' to connect the server - "PostgreSQL 13".

I've already tried all the "default" passwords I managed to find on the internet but the error is always the same:

FATAL: password authentication failed for user "postgres"

I've also tried not to insert any password with the resulting error:

fe_sendauth: no password supplied

I don't know what to do. In PostgreSQL 13 the authentication method is encrypted via scram-sha-256. I already tried to set the method to trust, restart the mac, and open pg Admin 4 that keeps asking me for the password to access the server.

I've also tried to use the command line tool but end up encountering the same errors.

Finally, this is how my pg_hba.conf looks like:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

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

PS. I've also tried to uninstall PostgreSQL 13, deleting the postgres user and re-download and re-install everything... nothing changed.


If someone could help me would become my savior, thanks beforehand!

21

There are 21 answers

3
dlam On BEST ANSWER

I ran into the same problem recently. The solution below works for me. I'm using Windows btw, so you should try equivalent commands in your OS.

  1. Change METHOD of all rows in your pg_hba.conf file from scram-sha-256 to trust
  2. Add bin folder of Postgres installation to path, if you haven't
  3. Open command prompt and enter psql -U postgres. You won't be asked for password here.
  4. Enter \password postgres
  5. Choose and confirm your password
  6. Revert pg_hba.conf to original state

Now you should be able to enter password for postgres in pgAdmin.

0
user1575148 On

Did Setup prompt you for a password while installing?

If not, uninstall PostgreSQL using Windows Add or Remove Programs, delete everything under C:\Program Files\PostgreSQL and re-install. This time, you should be prompted for a password for user postgres and use the same password in pgAdmin4.

0
Ejrr1085 On

In my case I installed PostgreSQL 10 and 13 on CentOS 8 by error, so I uninstall both PostgreSQL and installed PostgreSQL 13 following the instructions from PostgreSQL web site, no other website.

How to unistall PostgreSQL

How to install correctly PostgreSQL

And after I change the password postgres user/role by Terminal (pgAdmin 4 web postgres user/role is diferent and diferente service):

# sudo -i -u postgres
[postgres@server ~$] psql
postgres=# ALTER USER postgres PASSWORD 'postgres';
ALTER ROLE
postgres=# /q
[postgres@server ~$] exit
# sudo systemctl restart postgresql-13
0
Serhii On

There was exactly the same error. I thought that the problem was the wrong password, I changed it, but it turned out to be simpler. The server just didn't work :) So I started the server via the console and was able to connect.

0
Andy On

It happened to me as well after a computer re-start. PostgreSQL was not running and I had to spin it up manually. Once done, I just had to hit enter (no password).

0
Arman Fagradyan On

The following worked for me. Change METHOD of all rows in your pg_hba.conf file from scram-sha-256 to trust (C:\Program Files\PostgreSQL\14\data\pg_hba.conf). This will disable password for your DB. Click on any database in postgresql to use Query Tool.

In Query Tool type ALTER USER postgres WITH PASSWORD 'User_password'; postgres is default username, execute it. This way you can set up a password for your DB, after that go back to the first step and change it back from trust to scram-sha-256.

0
Saad AK On

Just type the password you enter to start your PC(user/admin password).

0
Amina K M On
sudo -i -u postgres

psql
ALTER USER postgres PASSWORD 'new_password';
\q
exit
2
eo_coder_jk On

Just for reference: I ran into the same issue on ubuntu-20.04 running postgresql-13.1. To solve it with this configuration I had to run the following commands in the terminal:

  1. sudo su postgres
  2. psql
  3. \password postgres
  4. enter your password twice

Afterwards, I could log in through pgAdmin4 as usual, providing the set password.

0
Nabil Jlasssi On

To disable the master password do the following:

Locate the "Config.py" file. It's usually located in "C:\Program Files\PostgreSQL\12\pgadmin 4\web" or "C:\Program Files (X86)\pgAdmin4\v4\web" In this directory create a new file named "Config_local.py" and add the line MASTER_PASSWORD_REQUIRED=False. If the "Config_local.py" already exist, edit it, and add the line at the bottom of the file. Save the file. Close PGAdmin4 and reopen it. You should now be able to access PGAdmin without the master password.

https://community.progress.com/s/article/pgadmin-4-ask-for-master-password

2
Alberto Luengo Cabanillas On

The method that worked for me (Windows 10 x64, PostgreSQL 13):

  1. Edit C:\Program Files\PostgreSQL\13\data\pg_hba.conf and set "METHOD" column values to trust (security breach, only for testing purposes)
  2. Open Powershell as admin, go to C:\Program Files\PostgreSQL\13\bin
  3. Type pg_ctl reload, press Enter.
  4. Launch pgAdmin again
1
Mohamed Ahmed On

This works for me every time I'm setting up.

  1. sudo -u postgres -i

  2. psql

  3. \password postgres

After that, enter your password twice.

Then use that password in the pgAdmin4.

2
Arun Prasad E S On

**Always type the password

  1. If you doing this first time, delete all the existing folders of PostgreSQL in program files and program files x64. Then run the installation again, it worked. Asking for new password.

  2. In case you remember the master password. The default user name is postgres enter image description here

0
afrothetics On

I had the same problem after installing pgadmin4, in that I was able to use a master password, but the postgres password was not accepted. After spending hours attempting to sync postgresql and pgadmin to recognize the postgres password, I finally deleted/removed the server identified in pgadmin4 and created a new one using the same hostname as the original. The postgres db was immediately recognized. I created other dbs, assigned users and exited. When I re-opened pgadmin4, both the master password and postgres were accepted and I was able to complete my work. Hope this helps others same some time and aggravation.

0
rebel_codeaz On

The answer by @dlam works. But the problem remains same. It doesn't accept password when I use psql I found a workaround by using psql -U postgres instead of psql. Or using SQL Shell(psql) also works That works fine. enter image description here

Any better solutions are welcomed!

0
Rakshith Rapaka On

I encountered the same scenario. In my case I did the following:

  • opened Postgres and stopped the server from running
  • changed the password by pressing on server settings
  • started the server

Now I am able to enter my new password in pgAdmin, it works fine.

0
Wacademy On

The method that worked for me (Windows 10 x64, PostgreSQL 16):

Check that the service is running.

  1. Type Service in window search box
  2. Locate the Postgresql-x64-16. Take note of your bit and postgres version
  3. Click the play button at the top to start the server if it is not started
  4. Relaunch pgAdmin 4
0
Devstorm On

Found a easy steps.

  1. Change METHOD of # IPv4 local connections row in your pg_hba.conf file from scram-sha-256 to trust.
  2. Change the Host name/address in Connection tab to "127.0.0.1" of the Server-PostgreSQL 13(14).
  3. Connect to Server-PostgreSQL 13(14) and input empty string.

Now you should be able to log in with username postgres and create Login/Group role for your specific database.

2
kbhit22 kbhit22 On

1-change the port number 2-click to postgreSQL13 3-go to connection and change port for 5432

0
James On

Edit the pg_hba.conf located in the data folder. At the bottom, where it starts: local all all scram-sha-256 change all instances of "scram-sha-256" to "trust", like... local all all trust Save the file and you should be able to get right in.

1
Jamila Ali On

i just wrote - "password" and it worked. In PostgreSql 15