nginx deny npgsql access to database
I'm developing asp.net mvc web project on top of mono framework, using nginx as web server and npgsql driver to access postgreSQL database.
The project run fine on nginx web server if no database involved. But when I use database, the site is throwing HTTP 500 error :
Failed to establish a connection to '127.0.0.1'.
Description: HTTP 500. Error processing request.
Stack Trace:
System.Exception: Failed to establish a connection to '127.0.0.1'. at Npgsql.NpgsqlClosedState.Open (Npgsql.NpgsqlConnector context) [0x00000] in :0
It seem that nginx block npgsql's access to database. Any idea how to fix it ?
fyi, I use nhibernate as ORM, mono 2.10 (on Windows).
Edit :
I'd crea开发者_Python百科ted a simple console project to test connection :
string connString = "Server=127.0.0.1;Database=unitydb;User Id=admin;Password=admin;";
NpgsqlConnection conn = new NpgsqlConnection(connString);
conn.Open();
conn.Close();
Console.WriteLine("Success");
Program run fine on .NET framework, but fail to connect to database on mono framework. So, the problem is with mono not nginx. Still, I don't know how to fix it.
Are you using Mono 2.10.2? There seems to be a problem with Npgsql and this mono version. Please, try 2.10.4. I was also having this problem and 2.10.4 fixed it. I hope it helps.
精彩评论