# Dropped connection from Postgres DB requires Stardog Server restart

**URL:** <https://community.stardog.com/t/dropped-connection-from-postgres-db-requires-stardog-server-restart/2483>\
**Category:** Bug\
**Created:** [May 28, 2020, 8:32pm UTC](https://community.stardog.com/t/dropped-connection-from-postgres-db-requires-stardog-server-restart/2483 "2020-05-28T20:32:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![arwesterinen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/arwesterinen/32/40_2.png) [@arwesterinen](https://community.stardog.com/u/arwesterinen)\
**Post date:** [May 28, 2020, 8:32pm UTC](https://community.stardog.com/t/dropped-connection-from-postgres-db-requires-stardog-server-restart/2483/1 "2020-05-28T20:32:56Z")

</div>

I had a delay in querying Stardog and Postgres of about a half hour (had to take a call). Things were working. After the delay ... Studio (even after restart) is returning the error ...

```auto
000012: Unable to execute virtual graph query. SQL string: SELECT "xx", "yy", "zz"
FROM "schema"."tableName"
WHERE "zz" = 'ABC' AND "yy" = 'george'

```

stardog.log indicates that ...

```auto
WARN 2020-05-28 16:23:27,716 [stardog-user-16] com.complexible.stardog.protocols.http.server.StardogUndertowErrorHandler:accept(64): Unexpected exception was handled by the server
org.postgresql.util.PSQLException: This connection has been closed.
at org.postgresql.jdbc.PgConnection.checkClosed(PgConnection.java:857) ~[postgresql-42.2.12.jar:42.2.12]
at org.postgresql.jdbc.PgConnection.createStatement(PgConnection.java:1756) ~[postgresql-42.2.12.jar:42.2.12]

```

I had to STOP the Stardog server and restart it to re-establish a connection. Then, things worked. I can't stop my Stardog server in production.

Ideas?

Andrea

---

<div class="post-metadata">

**Author:** ![arwesterinen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/arwesterinen/32/40_2.png) [@arwesterinen](https://community.stardog.com/u/arwesterinen)\
**Post date:** [May 29, 2020, 2:19am UTC](https://community.stardog.com/t/dropped-connection-from-postgres-db-requires-stardog-server-restart/2483/2 "2020-05-29T02:19:54Z")

</div>

Sharing here ... I tried setting ext.ConnectionRetryCount to 3 and ext.ConnectionRetryDelay to 5 in Studio's driver settings, for the Postgres driver.

The query tried to run in Studio, but what originally took about 1.5 mins ended after 10 mins with the 00012 message.

So, that change did something but still was not successful.

Andrea

---

<div class="post-metadata">

**Author:** ![arwesterinen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/arwesterinen/32/40_2.png) [@arwesterinen](https://community.stardog.com/u/arwesterinen)\
**Post date:** [June 5, 2020, 6:53pm UTC](https://community.stardog.com/t/dropped-connection-from-postgres-db-requires-stardog-server-restart/2483/3 "2020-06-05T18:53:44Z")

</div>

A quick update. After I restarted Stardog with the failed query and VG config above, Stardog could not establish the VG connection.

I had to remove the ext.\* settings and then everything worked.

Andrea

---

<div class="post-metadata">

**Author:** ![arwesterinen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/arwesterinen/32/40_2.png) [@arwesterinen](https://community.stardog.com/u/arwesterinen)\
**Post date:** [July 7, 2020, 7:46pm UTC](https://community.stardog.com/t/dropped-connection-from-postgres-db-requires-stardog-server-restart/2483/4 "2020-07-07T19:46:48Z")

</div>

To close this out .... We resolved this by setting Postgres' testOnBorrow and testWhileIdle TRUE, and setting timeBetweenEvictionRunsMillis to 2000.

Andrea

---

<div class="post-metadata">

**Author:** ![joelcds](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/joelcds/32/1561_2.png) [@joelcds](https://community.stardog.com/u/joelcds)\
**Post date:** [October 3, 2022, 1:58pm UTC](https://community.stardog.com/t/dropped-connection-from-postgres-db-requires-stardog-server-restart/2483/5 "2022-10-03T13:58:45Z")

</div>

![image](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/f/ff57826b715876ab3df35765ee9c3367f43ea9f3.png)  
Thanks! that worked for us!
