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

2.4K
Visualizações
Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections

Here my DockerFile :-

FROM openjdk:10
ENV AQUILA_HOME /data/config
#USER root
#VOLUME /tmp
ADD a2i-web-1.0.0-SNAPSHOT.jar app.jar
#RUN bash -c 'touch /app.jar'
ENTRYPOINT ["java","-jar","app.jar"]

My jar is spring boot application which requires postgres. I installed portgres locally and it is successfully runnning on my localhost. I am building DockerFile successfully by command

sudo docker build -t djtijare/a2i-web:v1 .

But while running it by command

sudo docker run -p 8080:8080 -t djtijare/a2i-web:v1

giving exception as :

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

I am running this docker command from directory containing DockerFile and my jar Do I need to set any configuration to run postgres?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can't access service which on the host using localhost from container, you had to use the ip address of your host to access.

This because: default docker will use bridge which will setup a internal network for your container, so when container use localhost, it doesn't mean the host, it mean the container self's network.

If insist on, a ugly solution is use --net=host.

Something like next:

sudo docker run --net=host -p 8080:8080 -t djtijare/a2i-web:v1

Then you can use localhost to visit host's service from container.

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