Sample Header Ad - 728x90

Could not open shared memory segment - Too many open files in system

1 vote
2 answers
207 views
I need some help of expert in Postgres. I'm getting a problem in my application. Problem: PG::InsufficientResources:
ERROR:  could not open shared memory segment "/PostgreSQL.1477116630": Too many open files in system
STATEMENT:  SELECT "work_orders".* FROM "work_orders" WHERE (created_at < '2025-04-07 19:58:00.668344' AND rascunho is true) ORDER BY "work_orders"."id" ASC LIMIT $1
I have tried some changes with AI help but no success. Here is my Postgres configuration: postgresql.conf:
listen_addresses                    = '*'
port                                = 5432
superuser_reserved_connections      = 3
unix_socket_directories             = '/var/run/postgresql, /tmp'
max_connections                     = 200
shared_buffers                      = 4864MB
effective_cache_size                = 14592MB
maintenance_work_mem                = 1216MB
checkpoint_completion_target        = 0.9
wal_buffers                         = 16MB
default_statistics_target           = 100
random_page_cost                    = 1.1
effective_io_concurrency            = 200
work_mem                            = 6225kB
huge_pages                          = off
min_wal_size                        = 1GB
max_wal_size                        = 4GB
max_worker_processes                = 10
max_parallel_workers_per_gather     = 4
max_parallel_workers                = 10
max_parallel_maintenance_workers    = 4
max_prepared_transactions           = 400
ulimit settings made in /etc/security/limits.conf:
postgres  soft  nofile  65535
postgres  hard  nofile  65535

root  soft  nofile  65535
root  hard  nofile  65535

nucleusdb soft  nofile  65535
nucleusdb hard  nofile  65535
Changes in the systemd service (/etc/systemd/system/postgresql.service.d/override.conf):
[Service]
LimitNOFILE=65535.
During the day I got a lot of these messages, here is a screen shot. 288 errors during 12 hours! screen shot of the error messages
Asked by Murilo Mistura (11 rep)
Apr 8, 2025, 09:32 PM
Last activity: Jul 9, 2025, 09:06 AM