【发布时间】:2020-04-16 14:30:49
【问题描述】:
我有一个简单的本地环境,其中包括 docker-compose:
version: '3'
services:
postgres-mydb:
image: 'postgres:11-alpine'
ports:
- "5433:5432"
volumes:
- ./pg_data:/var/lib/postgresql
environment:
POSTGRES_DB: docker_mydb_dev
POSTGRES_USER: user
POSTGRES_PASSWORD: password
最近当我尝试连接到数据库时:
psql postgresql://user:password@localhost:5433/docker_mydb_dev
我明白了:
psql: error: could not connect to server: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
我很困惑,我在网上找不到任何想法。
【问题讨论】:
-
PostgreSQL 服务器是否正在运行?
-
@jjanes - 是的,它运行。但似乎我缺少 pg_hba.conf 文件
-
我建议检查网络接口和端口。 postgres 是否在监听 0.0.0.0 ?
-
没有该文件将无法启动。也许文件在启动后被删除了。或者你找错地方了。
标签: postgresql docker docker-compose psql macos-catalina