0

I'm trying to setup a dev env for a small project, but I keep running into the same issue and after looking at many posts that did not solve my issue, I drcided to post.

  1. My pgAdmin is runnning on mt local machine (not in a container).
  2. My Postgres database is running in a container.
Unable to connect to server:

connection failed: connection to server at "::1", port 5432 failed: FATAL: password authentication failed for user "myuser"

From the error I assumed I had a typo, but there is none (I double and triple checked) and the password was correct.

I use a docker-compose file to create my container:

version: '3.8'

services:
  db:
    image: postgres:15
    container_name: film-db
    restart: unless-stopped
    environment:
      POSTGRES_USER: myuser
      POSTGRES_PASSWORD: mypassword
      POSTGRES_DB: mydatabase
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:

container running

pg adming server connection setting

I tried 127.0.0.1 and localhost, but nothing helped.

Password: mypassword (I copied and pasted it just to make sure - but it's not working).

I read about some issues like that, but they had both Postgres and pgAdmin runnning in Docker containers.

1 Answer 1

0

As I see it, the only problem is, that you defined environment as as key-value object. It should be a sequence instead, each line starting with -. (More information about the YAML syntax can be found here for example).

So, I assume, changing your docker-compose file like this should solve your problem:

version: '3.8'

services:
  db:
    image: postgres:15
    container_name: film-db
    restart: unless-stopped
    environment:
      - POSTGRES_USER: myuser
      - POSTGRES_PASSWORD: mypassword
      - POSTGRES_DB: mydatabase
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data

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

2 Comments

yeah there is that syntax but i checked and my docker-compose file is correct yml environment: - POSTGRES_USER: myuser - POSTGRES_PASSWORD: mypassword - POSTGRES_DB: mydatabase is not really correct if using key value pair the following is okay yml environment: - POSTGRES_USER= myuser - POSTGRES_PASSWORD= mypassword - POSTGRES_DB= mydatabase and the one i posted too
I don't quite understand your comment, but if you have tried it with - as well als with =, there should not be a problem. Your case was mentioned in this question as well, perhaps those answers can help you: stackoverflow.com/questions/45891599/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.