2013-10-17 34 views
1

我在我的应用程序中使用postgreSQL,但有时在固定的时间间隔后抛出NpgsqlException。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 

,请帮助,如果任何人知道我做错了。

在此先感谢。

+0

主机与数据库被命名为 “服务器”? – wiero

+0

我在我的代码中使用主机名。 – Attri

回答

1

转到下面的文件夹, Program Files文件\的PostgreSQL \ 9.4 \数据

在下面的章节中打开文件 '的pg_hba.conf' 和addline,

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