我有一个简单的本地环境,其中包括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.
我很困惑,在网上找不到任何想法。
答案 0 :(得分:0)
好-要解决此问题-之所以无法访问我的数据库(无论是否为docker),是因为我被要求在计算机上安装防火墙,并且阻止了对本地主机的访问。现在一切都按预期进行。
感谢您的帮助!