我正试图使用Postico连接到本地机器上的Docker PostgreSQL容器。我尝试连接0.0.0.0、localhost和127.0.0.1,但是每次都会出现以下错误:
这是我的Docker Compose文件:
could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
0.0.0.0 给我一个类似但更小的错误:
could not connect to server: Connection refused
Is the server running on host "0.0.0.0" and accepting
TCP/IP connections on port 5432?
这是我的Docker Compose文件:
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.23
restart: always
ports:
- "4466:4466"
environment:
PRISMA_CONFIG: |
port: 4466
databases:
default:
connector: postgres
host: postgres
port: 5432
user: prisma
password: prisma
migrations: true
postgres:
image: postgres:10.5
restart: always
environment:
POSTGRES_USER: prisma
POSTGRES_PASSWORD: prisma
volumes:
- postgres:/var/lib/postgresql/data
volumes:
postgres:
感谢 Egor 提供的解决方案!我忘记在我的 docker-compose 文件中指定 ports: - "5432:5432"
。这是初学者的错误;)
docker-compose.yml
文件中的端口,对我也起作用了!谢谢! - joshlsullivan