Search code examples
postgresqlazureremote-serverdatagripdatabase-connectivity

Remote postgres database disconnects frequently on azure


I have installed Postgres(11) on Azure, I am connecting to it using Datagrip client, The problem is it disconnects very frequently and connects back when I run some query, takes nearly 5 seconds to connect back. Here I am attaching a picture of AdvancedSettings which I have tried already but this doesn't seem to work, can you please suggest a solution so this stays connected for more than 10 mins at least.


Solution

  • The solution depends on who closes the connection.

    • If the connection is closed by the benighted Azure configuration, configure DataGrip so that it sends keepalive packets:

      On the Options tab, select the Run keep-alive query each N seconds checkbox, where N is a number of seconds after which DataGrip runs a keep-alive query again.

    • If the connection is closed by DataGrip, tell it not to do that:

      On the Options tab, deselect the Auto-disconnect after N seconds checkbox.