2

I have installed one open-source project from docker and that project has a database in PostgreSQL. Now I want to see the database from pgAdmin 4 and when I am trying to connect with "host.docker.internal" I am getting an error see image below.

enter image description here

2 Answers 2

1

Simply do mapping port for your PostgreSQL (which is running inside Docker). and from your pgAdmin4 you'll connect using localhost:<mapped_port>

If you're using docker-compose

services:
  postgre:
    ports:
      - "8080:5432"

If you're using docker-cli

docker run postgre -p 8080:5432

Then from pgAdmin4 connect to your database using localhost:8080

2
  • 1
    Thanks for the quick reply but the port is already mapped, still I am getting the same error
    – Owais Noor
    Commented Feb 11, 2021 at 8:17
  • from pgAdmin4 can you try connect using localhost? Commented Feb 12, 2021 at 4:05
0

I suspect this is a networking issue.

If port mapping does not work as suggested in other answers, try specifying the network as host for your container

If you are using docker run

--net=host 

Or use the following on docker compose

network_mode: 'host'

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.