我有
pgadmin
在 Docker 容器中运行(在我的浏览器中可用,网址为 http://localhost:8080)
Postgres 安装在我的系统中(不是 Dockerized),我可以使用以下方式连接到它:
import sqlalchemy
engine = sqlalchemy.create_engine('postgresql://bob:[email protected]:5432/postgres')
engine.connect()
问题是,当我在 pgadmin 中创建一个服务器,并尝试连接到主机名/地址 127.0.0.1,端口 5432,维护数据库 postgres,user bob,和password 1234,我得到:
Unable to connect to server: connection to server at "127.0.0.1", port 5432 failed Connection refused. Is the server running on that host and accepting TCP/IP connections?