我使用Homebrew在Mac上安装了Postgres 11.5。我还在/ etc / hosts中定义了一个postgres条目。在Mac上,我可以成功连接到数据库(psql -h postgres -U)。我还修改了postgresql.conf文件,使其具有:
listen_addresses = '*'
port=5432
我有一个运行的容器应用程序。登录此容器(docker exec ...
)后,可以成功ping postgres主机。但是当我输入psql -h postgres -U <username>
时,我收到一条错误消息:
psql: could not connect to server: Connection refused
Is the server running on host "postgres" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
我是否缺少Docker或Postgres配置?