Npgsql : is the server down or a bad password? Npgsql : is the server down or a bad password? postgresql postgresql

Npgsql : is the server down or a bad password?


with Npgsql v 3.0.2.0 (not sure about older versions) if the IP/hostname is wrong an Exception with code =-2146233083 with be thrown. if however the IP/hostname is correct but the port number is wrong Exception with code= -2147467259 with be thrown. if the IP/port is correct but username /password is wrong a NpgsqlException with code = "28P01" will be thrown.


You're probably using Npgsql 2.x; the new Npgsql 3.x throws NpgsqlException only when errors are received from a PostgreSQL server. Network connection errors are raised as SocketException etc. You're encouraged to upgrade.

By the way: I couldn't reproduce your exact findings even with Npgql 2.x, connecting to a wrong port or a wrong IP resulted in an NpgsqlException with Code being an empty string, not 28P01.