我正在尝试将部署在 render.com 上的 Flask 应用程序连接到 PostgreSQL 数据库。数据库已经可以与我的开发应用程序配合使用,但在尝试从部署的应用程序连接时遇到错误。
我使用 DATABASE_URL='postgres:{username}@{host}:{port}/{database_name}' 的正常格式
我对 pg_hba.conf 和 postgresql.conf 文件进行了以下更改,并使用 brew 重新启动了 postgresql:
pg_hba.conf:
local all all md5
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
host all all 0.0.0.0/0 trust
postgresql.conf:
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
尽管进行了这些更改,我在尝试连接时仍然收到以下错误:
Error connecting to database: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed:
Connection refused Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (127.0.0.1), port 5432 failed:
Connection refused Is the server running on that host and accepting TCP/IP connections?
(Background on this error at: https://sqlalche.me/e/20/e3q8)
我还需要配置或修改其他内容才能成功将 Flask 应用程序连接到 render.com 上的 PostgreSQL 数据库吗?
面临类似的问题,实际上我无法连接从渲染中获得的 postgresql 数据库 //错误 - MySQLdb.OperationalError: (2002, "无法连接到'name-postgres.render.com'上的服务器(138) "))\ -- IAM 正在制作登录页面
我使用内部和外部 url 与我的 Flaskapp 连接 - 格式:psql/: 用户名/密码/数据地址/数据库名称仍然无法连接,每次我尝试连接时都会出现此错误。 当我尝试使用 pgadmin4 服务器进行配置时,我插入了当前用户的登录数据。