0

I have a Docker Compose setup for a PostgreSQL container like below:

version: '3'
services:

  #PostgreSQL Service
  um-db:
    image: postgres:15
    container_name: um-db
    tty: true
    ports:
      - "5432:5432"
    environment:
      POSTGRES_DB: user_management
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: password
      PGDATA: /var/lib/postgresql/data/pgdata
      SERVICE_TAGS: dev
      SERVICE_NAME: postgresql
    volumes:
      - um-dbdata16:/var/lib/postgresql/data
    networks:
      - um-app-network

#Volumes
volumes:
  um-dbdata16:
    driver: local

After running docker-compose up -d --build, the database gets built successfully. However, after some time, it automatically gets dropped. Here's a snippet of the log:

docker logs um-db
2024-02-11 07:20:09.510 GMT [161] ERROR:  cannot drop the currently open database
2024-02-11 07:20:09.510 GMT [161] STATEMENT:  DROP DATABASE postgres;
2024-02-11 07:20:09.639 GMT [22] LOG:  checkpoint starting: immediate force wait
2024-02-11 07:20:10.449 GMT [165] FATAL:  password authentication failed for user "postgres"
2024-02-11 07:20:10.449 GMT [165] DETAIL:  Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"

The same setup is working fine on my Ubuntu server locally, but when deployed to a VPS, this issue occurs. I have thoroughly searched the internet for a solution but couldn't find any useful resources. Please point me in the right direction so that I can solve this issue.

1 Answer 1

0

The problem is 2024-02-11 07:20:10.449 GMT [165] FATAL: password authentication failed for user "postgres".

  • Are you sure its the correct password?
  • Your Volume is different from your Ubuntu machine to the VPS so check they are identical to rule out that issue.
  • Check your pg_hba.conf on the line mentioned. You might have editited a line above or below and therefore the wrong permissions are set.
  • You've not declared a network: section, is it on the same network as the thing your trying to connect to?

If these don't fix the issue, add your response & any other logs/errors and we will see fi we can get it sorted.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.