NpgsqlException无法与服务器建立连接

时间:2013-10-17 08:46:28

标签: c# asp.net networking npgsql entityspaces

我在我的应用程序中使用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

如果有人知道,请帮忙,我做错了什么。

先谢谢。

1 个答案:

答案 0 :(得分:1)

转到以下文件夹, Program Files \ PostgreSQL \ 9.4 \ data

在下一节

中打开文件'pg_hba.conf'和addline

IPv4本地连接: 主持人全部100.10.1.00/24 md5

其中100.10.1.00是您从中访问postgres服务器的服务器IP。

否则您可以添加以下行

主持全部0.0.0.0/0 md5

允许所有ips连接。 重启服务器并尝试。

将以下行添加到'postgresql.conf'文件

listen_address ='*' port = 5432

相关问题