# Error password authentication failed for user "postgres"

**URL:** <https://forums.docker.com/t/error-password-authentication-failed-for-user-postgres/119648>\
**Category:** General\
**Created:** [January 10, 2022, 5:59am UTC](https://forums.docker.com/t/error-password-authentication-failed-for-user-postgres/119648 "2022-01-10T05:59:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![anelso42](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@anelso42](https://forums.docker.com/u/anelso42)\
**Post date:** [January 10, 2022, 5:59am UTC](https://forums.docker.com/t/error-password-authentication-failed-for-user-postgres/119648/1 "2022-01-10T05:59:21Z")

</div>

I’m trying to connect to a Postgres image running on a docker container and I’m having trouble connecting to it.

```
version: '3.4'
services:
  postgres:
    image: postgres:alpine
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: password
      POSTGRES_DB: postgres
    logging:
      options:
        max-size: 10m
        max-file: "3"
    ports:
      - "5432:5432"

```

I know the container is successfully running on port 5432:

```
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a553b2135fcf postgres:alpine "docker-entrypoint.s…" 3 seconds ago Up 2 seconds 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp postgres

```

I tried to connect two ways.

**PgAdmin**

```
PgAdmin: General 
Name: postgres

PgAdmin: Connection
Hostname/address: 127.0.0.1
Port: 5432
Maintenance database: postgres
Username: postgres
Password: password

```

I received the following error:

```
Unable to connect to server:
FATAL: password authentication failed for user "postgres" 

```

**Visual Studio Code**

```
Hostname: 127.0.0.1
Postgres User: postgres
Postgres Password; password
Port number: 5432
Standard Connection 

```

I get the same error:

```
 password authentication failed for user "postgres"
```

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [January 10, 2022, 8:50pm UTC](https://forums.docker.com/t/error-password-authentication-failed-for-user-postgres/119648/2 "2022-01-10T20:50:59Z")

</div>

Can you connect from the container using the same username and password?

---

<div class="post-metadata">

**Author:** ![escote](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/escote/32/34290_2.png) [@escote](https://forums.docker.com/u/escote)\
**Post date:** [April 28, 2022, 1:43am UTC](https://forums.docker.com/t/error-password-authentication-failed-for-user-postgres/119648/3 "2022-04-28T01:43:39Z")

</div>

Envs are used by postgres initdb to create your postgresql instance. If you changed yours envs after first execution, you need to delete the postgres container to force a recreation using new envs. If you have defined a volume, you will also need to remove it.

---

<div class="post-metadata">

**Author:** ![ricsegundo](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/ricsegundo/32/35066_2.png) [@ricsegundo](https://forums.docker.com/u/ricsegundo)\
**Post date:** [June 19, 2022, 10:05pm UTC](https://forums.docker.com/t/error-password-authentication-failed-for-user-postgres/119648/4 "2022-06-19T22:05:44Z")

</div>

Hi there!  
Can the problem be the semi-colon after the password, on the VS Codedile:

**Visual Studio Code**

```auto
Hostname: 127.0.0.1
Postgres User: postgres
**Postgres Password; password**
Port number: 5432
Standard Connection 

```

---

<div class="post-metadata">

**Author:** ![dockerascodigo](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/dockerascodigo/32/36289_2.png) [@dockerascodigo](https://forums.docker.com/u/dockerascodigo)\
**Post date:** [September 8, 2022, 3:07pm UTC](https://forums.docker.com/t/error-password-authentication-failed-for-user-postgres/119648/5 "2022-09-08T15:07:54Z")

</div>

Hi, I am going through the same situation, from the container I can enter without problems, but when I do a get from my api it gives me that error. How did you fix it?

---

<div class="post-metadata">

**Author:** ![vithesh](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/vithesh/32/48872_2.png) [@vithesh](https://forums.docker.com/u/vithesh)\
**Post date:** [June 29, 2024, 9:09am UTC](https://forums.docker.com/t/error-password-authentication-failed-for-user-postgres/119648/6 "2024-06-29T09:09:26Z")

</div>

it will work if you change the local port attached to docker port  
something like 1234:5432  
i think its because postgressql is installed in the system and its listening to teh port 5432 and the port in docker is colliding with it.  
remove postgres from the system

---

<div class="post-metadata">

**Author:** ![comrade747](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/comrade747/32/55304_2.png) [@comrade747](https://forums.docker.com/u/comrade747)\
**Post date:** [January 4, 2025, 8:17pm UTC](https://forums.docker.com/t/error-password-authentication-failed-for-user-postgres/119648/7 "2025-01-04T20:17:49Z")

</div>

Excellent! thanks a lot

---

<div class="post-metadata">

**Author:** ![lukefer](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/lukefer/32/60547_2.png) [@lukefer](https://forums.docker.com/u/lukefer)\
**Post date:** [July 18, 2025, 5:23pm UTC](https://forums.docker.com/t/error-password-authentication-failed-for-user-postgres/119648/8 "2025-07-18T17:23:33Z")

</div>

If you run the container once with a different password and then restart it with another password, it won’t update the existing database because it’s already initialized. Try removing the old volumes or using a different volume.

---

<div class="post-metadata">

**Author:** ![khairulbasar](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/khairulbasar/32/62785_2.png) [@khairulbasar](https://forums.docker.com/u/khairulbasar)\
**Post date:** [December 11, 2025, 7:41pm UTC](https://forums.docker.com/t/error-password-authentication-failed-for-user-postgres/119648/9 "2025-12-11T19:41:00Z")

</div>

Thank you very much, Bro  
I stacked for two days, you help me to find out what’s the problem.

grateful to you 😍

---

<div class="post-metadata">

**Author:** ![linus4566](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/linus4566/32/65176_2.png) [@linus4566](https://forums.docker.com/u/linus4566)\
**Post date:** [July 7, 2026, 8:52pm UTC](https://forums.docker.com/t/error-password-authentication-failed-for-user-postgres/119648/10 "2026-07-07T20:52:29Z")

</div>

Thank you very much!!
