首页 > 解决方案 > 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 连接字符串添加超时参数,但它仍然无法正常工作,仍然出现相同的错误。

标签: c#asp.netpostgresqlvirtual-machineconsole-application

解决方案


推荐阅读