46

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!

3
  • I'm assuming this is the Windows install. Use the master password, it is also the password for postgres user. Commented Oct 4, 2020 at 20:45
  • Hi I'm running into the exact same issue, did you find a solution for this? Commented Nov 10, 2020 at 0:19
  • 1
    People looking for Pgadmin4 password on StackOverflow should be a hint that it's retarded feature and totally useless. Commented Aug 17, 2022 at 18:04

24 Answers 24

53

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Which version is this for? psql -U postgres still asking the password in step 3.
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.
This worked perfectly for me running PostgreSQL 14
29

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.

3 Comments

sudo was the key for me. It asked for a password without that even though none was set.
This is the solution that worked for me after I tried several other answers and none worked. It also is the cleanest most straightforward without need to edit configurations as suggested by other answers here and in other channels.
This answer worked for me as well. No additional rabbit holes, just worked with only three terminal commands
8

**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

2 Comments

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 I kept my password the same but typed it out instead of pasting it and it worked! ty!
6

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

2 Comments

This worked for me (Windows 10 x64, PostgreSQL 14) thanks!!
For me, pg_ctl was giving error. So I restarted PostgreSQL service & pgadmin. It started working after that.
4

After installing PostgreSql, do the following:

sudo -i -u postgres

psql
ALTER USER postgres PASSWORD 'new_password';
\q
exit

1 Comment

That's solved my issue thx.
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

Comments

2

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.

Comments

2

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

Comments

2

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.

Comments

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

Comments

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.

Comments

1

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

1 Comment

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

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.

Comments

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.

Comments

0

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.

1 Comment

You should improve your answer, because there are so many upvoted answers which have the same instruction but with more details.
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.

Comments

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

Comments

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!

Comments

0

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

2 Comments

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
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
0

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

Comments

0

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.

Comments

0

Closing the VPN fixed the issue.

Comments

0

pg Admin 4 on windows, I followed this steps and it worked for me

  1. Goto Login/Group Roles and right click on postgres enter image description here
  2. Click on properties enter image description here
  3. Click on "Definition tab", enter password and save enter image description here

Comments

0

If you know some user that you already know the password you can edit it, you can also use a specific database.

psql -d <database-name> -U <username>

afterwards, you can use (you need to have privileges for this)

\password postgres

Note: This works on psql 16 I don't know if works on other versions

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.