[Bug]: sorry, too many clients already | 5000+ photos
⚠️ This issue respects the following points: ⚠️
- [X] This is a bug, not a question or a configuration/webserver/proxy issue.
- [X] This issue is not already reported on Github (I've searched it).
- [X] Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- [X] Maps app is up to date. See Maintenance and Release Schedule for supported versions.
- [X] I agree to follow Nextcloud's Code of Conduct.
Bug description
I am experiencing postgresql errors related to the number of connected clients and my Nextcloud instance become unresponsive (db connection missing for other tasks).

I think the error is related to the requests that are made to retrieve photos data from the db. I have 5000+ photos that have to be shown on the map so the connection towards the db is saturated.
Steps to reproduce
- Go to
/apps/maps/ - Wait to load
- Error
Expected behavior
Load images without DB error.
Installation method
Official Docker image
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.0
Web server
Apache (supported)
Database engine version
PostgreSQL
Is this bug present after an update or on a fresh install of the server?
None
Is this bug present after an update or on a fresh install of the app?
None
Are you using the Nextcloud Server Encryption module?
None
What user-backends are you using?
- [X] Default user-backend (database)
- [ ] LDAP/ Active Directory
- [ ] SSO - SAML
- [ ] Other
Configuration report
v24.0.7
List of activated Apps
Different apps, the problem appears only when I try to load the map page
Nextcloud Signing status
No response
Nextcloud Logs
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[08006] [7] FATAL: sorry, too many clients already
Browser Console
No response
Additional info
No response
I think the problem could be in this foreach: https://github.com/nextcloud/maps/blob/master/lib/Service/GeophotoService.php#L78
Can this logic be changed to group multiple queries in less requests on the db?
Yes probably.
Can this logic be changed to group multiple queries in less requests on the db? Yes probably
But I think the proper way to fix this is to find the files via a dav search request for metadata.
Is dav used for other operations in this app? I can test if you need validation on this bug
Not really. But everywhere else in nextcloud.
same issue here with Nextcloud 27.0.0. I have only a small amount of images in Nextcloud (< 50). The error occurs if I open the Photos overview. I have to restart the docker containers to continue working with Nextcloud.
I'm running into the same issue with version 27.0.1 deployed via official docker using PSQL. This only started after I updated to the latest version. Is there any fix for this yet?
For me, deactivation of some plug-ins fixed it. Unfortunately I don't remember which plug-in it was.