我正在尝试使用Postico连接到本地计算机上的docker postgreSQL容器。
我尝试连接到0.0.0.0,localhost和127.0.0.1。每个给我以下错误:
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"
。新秀错误;)
答案 0 :(得分:1)
如果postgres版本无关紧要,请尝试将Postgres图像更改为此版本,
还要确保您在docker-compose.yml
postgres:
image: postgres
restart: always
environment:
POSTGRES_USER: prisma
POSTGRES_PASSWORD: prisma
ports:
- "5432: 5432"
volumes:
- postgres:/var/lib/postgresql/data
P.s。刚刚更新了可读性答案
答案 1 :(得分:0)