30

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!

jarlh
  • 42,561
  • 8
  • 45
  • 63
Masso
  • 327
  • 1
  • 3
  • 6

18 Answers18

43

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.

dlam
  • 446
  • 4
  • 3
  • Which version is this for? `psql -U postgres` still asking the password in step 3. – roe Nov 09 '20 at 08:42
  • 1
    I use PostgreSQL 13. Did you forget to save conf file in step 1? Also try editing with Notepad++ and running command prompt as administrator to see if it can make a difference. If nothing helps, try downloading a new installer as it now provides password prompt during installation. – dlam Nov 10 '20 at 23:40
  • This worked perfectly for me running PostgreSQL 14 – NoName123 Jun 25 '22 at 09:02
18

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.

eo_coder_jk
  • 181
  • 1
  • 5
5

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
3

If you doing this first time, delete all the existing folders of PostgreSQL in program files and program files 64.

Then run the installation again, it worked. Asking for new password.

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

Arun Prasad E S
  • 9,489
  • 8
  • 74
  • 87
  • 1
    This is the right answer. For some reason the password if pasted in or if too complex (not sure which) will not work later... – its.me.adam May 26 '23 at 19:14
3

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

BFH
  • 131
  • 1
  • 3
2

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

Saad AK
  • 45
  • 3
1

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
Ejrr1085
  • 975
  • 2
  • 16
  • 29
1

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.

Raphael
  • 517
  • 4
  • 18
1

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.

1
sudo -i -u postgres

psql
ALTER USER postgres PASSWORD 'new_password';
\q
exit
Adriaan
  • 17,741
  • 7
  • 42
  • 75
Amina K M
  • 15
  • 3
0

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.

user1575148
  • 561
  • 6
  • 28
0

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.

James
  • 191
  • 11
0

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.

afrothetics
  • 101
  • 1
0

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).

Andy
  • 1,307
  • 1
  • 12
  • 17
0

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!

rebel_codeaz
  • 101
  • 1
  • 7
0

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

  • It said FATAL: password authentication failed for user "postgres" If it was wrong port, the error msg would indicate that :) Always make sure you understand the question. Welcome to stackoverflow and please check this: https://stackoverflow.com/help/how-to-answer – Rabhi salim Sep 05 '22 at 15:03
  • It said FATAL: password authentication failed for user "postgres" If it was wrong port, the error msg would indicate that :) Always make sure you understand the question. Welcome to stackoverflow and please check this: stackoverflow.com/help/how-to-answer – Rabhi salim Sep 05 '22 at 15:03
0

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

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 26 '23 at 14:36
-1

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.