Unable to connect to server: connection failed: connection to server at "127.0.0.1", password authentication failed

Hi Everyone, so I am trying to run a docker compose file, in my app which spins up multiple containers, out of which one is a postgres instance.

Now I want to connect to this postgres instance, through my host machine’s (Windows) pgAdmin, but whenever I try connecting I get the following issue:

Unable to connect to server:

connection failed: connection to server at "127.0.0.1", port 5432 failed: FATAL: password authentication failed for user "test_postgres_user"

The configuration I used on pgAdmin is:

and ssl is disabled for the same.

This is my .env file:

DEPLOYMENT='local'

POSTGRES_DB=test_postgres_db

POSTGRES_USER=test_postgres_user

POSTGRES_PASSWORD=changeme

POSTGRES_HOST=test_postgres_db

NODE_ENV=development

And this is my docker.compose file
version: ‘3.8’

services:
  test_postgres_db:
    image: postgres:14-alpine
    env_file: .env
    environment:
      - POSTGRES_DB=test_postgres_db
      - POSTGRES_USER=test_postgres_user
      - POSTGRES_PASSWORD=changeme
    container_name: test_postgres_db
    ports:
      - 5432:5432
    networks:
      - test_network

My Docker ps
b5c2a6d86fde postgres:14-alpine test_postgres_db "docker-entrypoint.s…" 2 hours ago Up 2 hours 0.0.0.0:5432->5432/tcp, [::]:5432->5432/tcp

And when I try running : docker exec -it test_postgres_db psql -U test_postgres_user -d test_postgres_db

I am able to access the postgres container.

Furthermore, I have even done docker inspect containerId , and tried connecting through the ipaddress given in the info, but then the issue changes to

Unable to connect to server connection timed out

Now can anyone tell me what is going wrong , and how can I connect to the same?

It is vital I get it working rn, cause I am unable to test stuff and its hampering development

PS I am on windows, if that helps

Thank you

You run the Docker containers on Windows in WSL?

Yep I run it on windows in wsl

You didn’t mention Docker Desktop, are you running docker-ce on a WSL2 distribution?

This can not work if the container is running in a WSL2 distribution, and pgadmin runs on Windows, regardless whether Docker Desktop is used, or docker-ce is installed in a wsl2 distribution,

Are you sure you shared the right compose file? It was incomplete. I had to the top level networks section to make it work, and used the tag 17-alpine.

Appart from that: the compose file deploys the container just fine in Docker Desktop, and I can access it from pgadmin4 using the configuration from the screenshot, of course the password being changeme.