Search code examples
postgresqldockerdocker-composenestjspgadmin-4

How configure docker / pgadmin with nest


I'm trying to configure my docker to pgadmin4 in my nest js project, to do the backend, but when i try connect, show this message "Unable to connect to server:

could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting"

I already tried configure the docker-compose.yml with pgadmin configurations, network configurations and

my docker-compose.yml

version: '3'
services:
  db:
    image: postgres
    environment:
      POSTGRES_PASSWORD: "12345678"
    ports:
      - "5432:5432"
    volumes:
      - ./data/pgadmin/
    networks:
      - pg-network

  pgadmin:
    image: dpage/pgadmin4
    environment:
      PGADMIN_DEFAULT_EMAIL: "monnerat@monnerat.com.br"
      PGADMIN_DEFAULT_PASSWORD: "abc"
    ports:
      - "5050:80"
    depends_on:
      - db
    networks:
      - pg-network

networks: 
  pg-network:
    driver: bridge

My actual result is connection refused is server running on host "localhost (127.0.0.1) and accepting" but i expect he open the pgadmin to create the database


Solution

  • Your docker-compose.yml is good. Please see the attached host name should be 'db'

    enter image description here