We are using GeoServer with a geoserver cache for some layers. Most of our layer updates frequently and therefore we do not want to setup a cache for them (they do have in memory cache though).

First, we use different workspaces for different types/actions we want to perform and want to keep the different workspaces/layers separate, however they all connect to the same PostGIS database.

Now I am facing a problem where we have 15+ workspaces, each workspace has a connection pool (default 10) to the same PostGIS DB. So that means that our GeoServer instance is taking more connections that PostGIS has (100), also we do have other applications running on the same database.

The connection pool for each store has a max connections = 10, min connections=1, connection timeout = 10, evictor run periodcity = 30, max connection idle time = 30, evictor tests per run = 3.

I noticed that PostGIS has a lot of connections on idle and does not close them. What is the best way of connection GeoServer to a PostGIS database with the minimum connections? How can I force the idle connections to close without changing the max connections?

  • you need to go into the backend and explicitly terminate these idle connections you speak of
    – ziggy
    Commented Dec 2, 2019 at 19:23
  • @ziggy, thanks for the reply. Currently I do this, however, this is not maintainable as I cannot manually end these idle connections on a daily basis Commented Dec 3, 2019 at 8:25

1 Answer 1


The easiest answer is to increase the number of connections at the PostGIS end.

If you want to limit the number of connections used by GeoServer specifically, then you have two options:

  1. Reduce the max number of collections on each of your data stores. This will probably increase the load time for your layers.

  2. Introduce a single pool for all of the servlets in tomcat, to do this set up a JNDI connection pool in your tomcat server. You can then use this shared pool in all of your datastores.

  • As I understand with the JNDI connection pool is that your database should be a PostGIS JNDI database, I only have a PostGIS database, this database is also in the cloud so I do not have an SSH connection to the database. I thought of using a single pool (moving all the layers into a single workspace. But if I do this then I do not have the control on how much connections a particular "workspace" (in this case a layer) can use, so if we view one layer that layer will receive most connections and it won't be distributed evenly? Commented Dec 3, 2019 at 10:36
  • JNDI just describes how the connections are handled - there is no difference at the server end
    – Ian Turton
    Commented Dec 3, 2019 at 10:44
  • Ok Cool will try this out, thanks Commented Dec 3, 2019 at 12:08
  • Even if I set the max connections to 10 on my GeoServer Store, it can still leave dozens of idle connections open especially in the case of using SET SESSION AUTHORIZATION on the Store.
    – A. Mort
    Commented Nov 12, 2023 at 2:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.