Mahmoud Nafiseh
Mahmoud Nafiseh

Reputation: 171

Can't connect to postgres with Adminer using Docker on MacOS

I'm trying to connect to a postgres database using Adminer on MacOS

Here is my Makefile:

.PHONY: postgres adminer migrate

postgres:
    docker run --rm -ti -p 5432:5432 -e POSTGRES_PASSWORD=secret postgres


adminer:
    docker run --rm -ti  -p 8080:8080 adminer

migrate: 
    migrate -source file://migrations \
            -database postgres://postgres:secret@localhost:8080/postgres?sslmode=disable up

When I try connecting this is what I get:

error

I tried looking for answers, tried this command:

docker run --rm -ti --network host -e POSTGRES_PASSWORD=secret postgres

But it also did not work and I got the same error. Can I get some help please?

Upvotes: 0

Views: 80

Answers (1)

Mahmoud Nafiseh
Mahmoud Nafiseh

Reputation: 171

I fixed this by putting host.docker.internal:5432 as the server instead of localhost.

Upvotes: 0

Related Questions