c# - NpgSql 无法与 PostgreSql 建立连接
问题描述
我正在将 npgsql 2.2.7 与 asp dot net 控制台应用程序一起使用,并且应用程序可以与我本地 PC 上的 azure postgres DB 正常连接。从我的Azure VM运行它时出现连接超时错误。即使我也可以使用 Azure VM 中的 pgAdmin 连接我的 azure postgres db。
Npgsql.NpgsqlException:
Failed to extablish a connection to protgres.database.azure.com
at Npgsql.NpgsqlCloseState.Open(NpgsqlConnector context, Int32 timeout)
at Npgsql.NpgsqlConnector.Open()
at Npgsql.NpgsqlConnection.Open()
我的 postgres SQL 连接字符串:
<add name="DbConnectionString" connectionString="User Id= ;Password= ; Server= ;Port=5432;Database= ; SslMode=Require" providerName="Npgsql" />
尝试使用 postgres 连接字符串添加超时参数,但它仍然无法正常工作,仍然出现相同的错误。
解决方案
推荐阅读
- python - 从 google cloud dataproc python notebook 运行 .py 文件
- python - Postgres SQL 错误:没有与 ON CONFLICT 规范匹配的唯一或排除约束”尽管设置了约束
- python - 如何验证依赖下拉列表?
- javascript - 将数据从一个数组重新排列到另一个数组的不同方法
- tortoisesvn - 如何从命令提示符打开 Tortoise SVN 提交 UI
- python - 为什么从 CSV 文件导入数据时出现此 DBeaver 错误?
- python - 模板列表的第一个元素/Django
- python - 如何为两个列表框使用单个滚动滑块
- algorithm - 如何在处理中使用 Bresenham 的线算法在网格中创建一条线
- python - ValueError:密集层的输入 0 不兼容