Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am getting error

Npgsql.NpgsqlException


{"Failed to establish a connection to 'remotServerIP'}

If any body have solution so plz provide
Posted
Comments
jim lahey 10-May-11 9:52am    
you'll need to provide a lot more information than this, or I'll be forced to assume you're genuinely trying to connect to 'remotServerIP'

1 solution

If you have a local server (installed npgsql in your own system) use 'localhost' for the server

Here's an example connection string
Server=localhost;Database=db1; User Id=xxx; Password=xxx;

PostgreSql normally installs on port 5432. If you've installed on a different port add the port to the connection string
Eg: Port=5432;
(To find out your port, go to the pgsql data directory & open postgresql.conf & check in it)
 
Share this answer
 
Comments
vishnushanmughan 10-Nov-14 7:55am    
I am having same problem ,but i am not using a local server so what should i do ?
it shows "Failed to establish a connection to '[ip-address of db-server]'"
strogg 14-Nov-14 13:58pm    
On your server, go to your data directory, open postgresql.conf and uncomment the line listen_address (remove #) - set it to: listen_address = '*'
Restart your pgsql server. make sure your server's firewall is allowing port 5432. Temporarily turn off your firewall to test if you like.
vishnushanmughan 15-Nov-14 5:29am    
I tried everything you commented but it still not working same error "Failed to establish a connection to '[ip-address of db-server]'" is showing
strogg 16-Nov-14 9:40am    
Go to data directory, open the file 'pg_hba.conf' and add the line
-----
# IPv4 local connections:
host all all 192.168.1.10/24 md5
-----
where 192.168.1.10 is the remote ip from which you will access postgres server. Or you can use
---
host all all 0.0.0.0/0 md5
---
which should allow all ip addresses to connect.
Replacing 'md5' in the line with 'trust' will allow users to connect without a password. Restart server and try.
Don't forget to add these lines to 'postgresql.conf' file
---
listen_address = '*'
port = 5432
---
If you omit port, it should default to 5432. Turn firewall off while testing. It's better you test on a local network. If you're trying to access it through the internet, you must forward the port you use through the router as well. Hope this helps
vishnushanmughan 21-Nov-14 7:20am    
yep.It worked but some times the connection is getting timed out

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900