Npgsql异常 无法建立与服务器的连接
本文关键字:服务器 连接 建立 异常 Npgsql | 更新日期: 2023-09-27 18:35:40
我在我的应用程序中使用了postgreSQL,但有时它会在固定的时间间隔后抛出NpgsqlException。
下面是异常的堆栈跟踪:
Exception message: Failed to establish a connection to 'server'.
at EntitySpaces.Interfaces.esDataProvider.esLoadDataTable(esDataRequest request, esProviderSignature sig)
at EntitySpaces.Interfaces.esDynamicQuery.Load()
at BusinessObjects.Users.ValidatePassword(String UserName, String Password) in e:'Code'Entities'Custom'Users.cs:line 50
at PassiveSTS.Login.Login_Authenticate(Object sender, AuthenticateEventArgs e) in e:'Code'STS'Login.aspx.cs:line 32
at System.Web.UI.WebControls.Login.AttemptLogin()
at System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Failed to establish a connection to 'server'.
at Npgsql.NpgsqlClosedState.Open(NpgsqlConnector context) in C:'Npgsql'NpgsqlClosedState.cs:line 171
如果有人知道,请帮助,我做错了什么。
提前谢谢。
转到以下文件夹,Program Files''PostgreSQL''9.4''data
打开文件"pg_hba.conf"并在下一节中添加行,
IPv4 本地连接:托管所有 100.10.1.00/24 MD5
其中 100.10.1.00 是您从中访问 Postgres 服务器的服务器 IP。
否则,您可以添加以下行,
托管所有 0.0.0.0/0 MD5
允许所有 IP 连接。重新启动服务器并尝试。
将以下行添加到"postgresql.conf"文件
listen_address = '*'端口 = 5432