Npgsql Exception while reading from stream, Postgres Npgsql Exception while reading from stream, Postgres postgresql postgresql

Npgsql Exception while reading from stream, Postgres


conn = new NpgsqlConnection("Server=myserver;User Id=postgres;Password=somepw;Database=somedb;Pooling=false;Timeout=300;CommandTimeout=300");

I added the CommandTimeout property to my connection string and it seems to be working now. Weird exception for a timeout error...


Please try the setting

KeepAlive = 300

The number of seconds of connection inactivity before Npgsql sends a keepalive query. Set to 0 (the default) to disable.

See the documentation.


In my case there was a firewall issue between the Docker container running the web app, and the Postgres server.