Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

384
Visualizações
Cannot connect to Docker PostgreSQL container in AWS EC2 instance

Docker newbie here.

I'm trying to create a docker container for PostgreSQL in AWS EC2 instance.

First, to achieve persistence I use data volume container. Here is the command I used to create a data volume container for my PostgreSQL database:

docker create -v /var/lib/postgresql/data --name postgres9.3.6-data busybox

Then I run the following command to create the PostgreSQL container:

docker run --name postgres9.3.6 \
-p 5432:5432 \
-e POSTGRES_PASSWORD=password \
-e POSTGRES_USER=root \
-e POSTGRES_DB=db_name \
-d --volumes-from postgres9.3.6-data postgres:9.3.6

I run this in my local environment and then tried to connect to it through a PostgreSQL desktop client and it worked. I was able to connect to the db_name that is stored in local PostgreSQL docker container.

After this, I sshed into one of my EC2 instances in AWS. And followed the same flow I described above. Then returned back to the PostgreSQL desktop client and tried to connect to it. But I got the following error message:

Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

What am I missing here?

Edit

I've already checked and set the listen_addresses on postgresql.conf file to

listen_addresses='*'

and appended the following line to pg_hba.conf file:

host all all 0.0.0.0/0 md5
over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

The postgresql.conf and pg_hba.conf look good. The docker run correctly publish postgresql port. Check your EC2 inbound rule, probably port 5432 is not allowed to be accessed.

over 4 years ago · Santiago Trujillo Relatório

0

You must edit postgresql.conf, set the listen_addresses parameter to '*':

listen_addresses = '*'

Also edit pg_hba.conf accordingly.

over 4 years ago · Santiago Trujillo Relatório

0

You need the give the host Id as well. loggin into postges container by docker exec -it /bin/bash

open the host file and last line in the file is host id. the file is available in etc directory and file name is host.

add use the host id instead of 0.0.0.0

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda