Payments are experiencing issues due to temporary restrictions in Russia. If your payment does not go through, please submit a support request.Our support team is available 24/7 — we are always here to help with hosting and server issues.We are now accepting requests for dedicated server rental and colocation services in our data center.Reminder: we recommend enabling backups for additional data protection.A new VPS/VDS lineup with NVMe storage and improved performance is now available.Maintenance work on some servers has been completed. All services are operating normally.
Article5 min readViews1

Too Many Open Files: Checking the Limit of a Running Process

The error may affect a single process even if free memory and disk space remain. The Ubuntu 24.04 guide shows where to read the active limit and how to distinguish it from the current terminal settings.

Comments 0

Open filing cabinet drawers with paper folders serve as a metaphor for open files. Generated illustration.
In this article

The application stopped opening files or accepting connections and reports Too many open files. Free gigabytes on the disk may have nothing to do with this. In Linux, file descriptors are used not only for regular files but also for sockets, channels, and other objects. First, check the process that received the error rather than increasing all limits on the server.

Applicability: Ubuntu 24.04 LTS, utility prlimit from util-linux 2.39.3, GNU coreutils 9.4, and the accessible file system proc. Verified via documentation on September 26, 2026. All commands below read the state. Changing limits, configuration, or restarting services is outside the scope of this instruction. Reading another process may require administrator-granted permissions; access denial should not be bypassed by modifying security settings.

Find the process associated with the error

Obtain the identifier from the application message, log, or a verified process list. A service may have a main process and several worker processes: an error in one worker does not mean the main process has exhausted its limit. After a restart, identifiers change, and the old number may eventually be assigned to a different program.

In all teams, PID is a placeholder. Replace it with a verified numeric identifier for the required process, without angle brackets. Run the commands in the environment where this process is visible. The process ID inside the container and the ID on the host may differ. If the process has already terminated, its current state cannot be read; only logs and previously collected metrics remain.

prlimit --pid PID --nofile

Here, the parameter --nofile has no equals sign or numeric value: the command displays the limit without setting a new one. Do not copy examples with --nofile=... from the configuration instructions instead, as they change the state.

As a result, find the line NOFILE and the columns SOFT and HARD. The soft limit is currently active, while the hard limit sets the ceiling for its normal increase by the unprivileged process itself. Strictly speaking, the limit restricts the number of the new descriptor: it is one greater than the maximum allowed number. Therefore, the count of open objects is useful for diagnostics but is not an exact universal counter of "remaining slots."

The same information can be read in the process limits list:

cat /proc/PID/limits

You need the string Max open files. This is the actual runtime state, not just an intention from a configuration file. The value read by the command ulimit -n in your terminal applies only to that shell and proves nothing about a long-running server process.

Check which objects remain open

ls -l /proc/PID/fd

The directory contains entries with numeric names. A standard path points to a file, an entry like socket:[...] points to a socket, and pipe:[...] points to a pipe. You may also encounter anonymous kernel objects. This is not a list of files consuming disk space: hundreds of network connections also use file descriptors.

To view only the numbers without decoding their purposes, use:

ls -1 /proc/PID/fd

This is a snapshot of a changing state. While the team reads the catalog, the program may open and close objects. A message about a missing link does not necessarily indicate system corruption. If access fails or the catalog is unavailable, do not interpret an empty result as zero open file descriptors.

With a large number of objects, the output can become lengthy and create extra work. Do not run frequent scans of all processes on a busy server. For an initial analysis, a selected process and a few observations spaced over time are sufficient. Before sharing the output, remove sensitive file names: they may reveal the project structure or client data.

Match the error, the limit, and the observation moment

In a conditional example, the soft limit is 1024, and at the moment of failure, almost all available numbers are in use. This is a reason to investigate which operations are holding the descriptors: connections to external services, unclosed files, or a growing client pool. If the count returns to normal after the load ends, the picture differs from continuous growth under stable load.

A single late snapshot is insufficient. The error could have occurred during a brief spike, after which the application closed some objects. Conversely, a large current list without errors does not prove a leak. You need the event time, the correct process, and the dynamics relative to its normal operation.

The error EMFILE relates to the process file descriptor limit. ENFILE refers to the system-wide limit on open files; this is a different diagnostic level. Application text may hide the original error code, so if possible, save the full message. Thoughtlessly increasing the limit for a single process is not a solution to a system problem and may only delay the manifestation of a leak.

In the Ubuntu 24.04.3 test environment with util-linux 2.39.3, reading via prlimit was performed for a separate child process: both limits of 16384 were retrieved. Reading its directory proc in this environment proved inaccessible, so the full descriptor viewing scenario on the test stand remains unconfirmed. Directory reading commands were cross-checked against Linux and GNU coreutils documentation; their result on your server depends, among other factors, on process space and permissions.

For the next stage of the investigation, save the error timestamp, process identifier, and process role, along with the active limits and the nature of the open objects. These data points help determine whether a load review and connection pool adjustment, a leak fix, or a justified configuration change is needed. This instruction does not recommend raising the limit before the cause is identified.

Discussion 0

Share your experience and ask questions. Comments without links appear after editorial review.

No comments yet. Start the discussion.