The usual default is 1024 and is often not enough. We recommend setting this to 40000 to ensure Neo4j works correctly. We previously learned how to monitor linux open file usage, now let’s see how to change this.

It is possible to set the limit with the ulimit -n command, but only for the root user, and it only affects the current session,
so it’s not permanent. Also, it will not affect your processes that are already running.

The actual way to raise your file limits consists of editing three files:

/etc/security/limits.conf needs to have these lines in it:

neo4j soft nofile 40000
neo4j hard nofile 40000

/etc/pam.d/common-session needs to have this line in it:

session required pam_limits.so

/etc/pam.d/common-session-noninteractive also needs to have this line in it:

session required pam_limits.so

Keep in mind that limits can be easily modified by anything responsible for execution of your processes. If running ulimit -n
(with the correct user) is giving you the number you just set, but cat /proc/{process_id}/limits is still printing the low number,
you almost certainly have a process manager, an init script, or something similar overriding your limits. One last thing worth noting
is that processes inherit the limits of the parent process.

In some cases, you also need to edit /etc/systemd/system.conf and /etc/systemd/user.conf in order for your limit configuration
to persist.