Unable to increase file descriptors for rabbitmq
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
When running RabbitMQ, especially under high-load scenarios or when dealing with many connections and queues, you might encounter issues related to file descriptor limits. File descriptors are crucial system resources, and RabbitMQ uses them for sockets and files. If RabbitMQ runs out of file descriptors, it can lead to lost connections, inability to open new connections, and even service interruption. Understanding how to properly increase the file descriptor limit is essential for maintaining a robust RabbitMQ setup.
Understanding File Descriptors
A file descriptor is a low-level resource managed by the operating system that represents an open file, socket, or another resource like a pipe or FIFO. Each open connection to RabbitMQ, and other tasks such as logging, requires one or more file descriptors. By default, the number of available file descriptors might be too low for medium to large RabbitMQ installations.
Checking Current Limits
Before attempting to increase the file descriptor limit, you should check the current limits imposed by the system. You can do this in several ways:
- Using RabbitMQ CLI tools: Run
rabbitmqctl statusto check the limits under thefile_descriptorssection. - Inspecting system limits: On Unix-like systems, you can use
ulimit -nto view the current limit for the shell session.
Increasing File Descriptors in Unix/Linux Systems
On Unix-like systems, there are two levels at which file descriptor limits can be set:
- System-wide limits: Controlled via
/etc/security/limits.conffor systems usingpam_limits.so, or similar configuration files for other systems. - Service-specific limits: For systems using systemd (common with newer distributions) limits can be set specifically for the RabbitMQ service.
Editing limits.conf
To increase the file descriptor limits system-wide, edit the /etc/security/limits.conf file and add or modify entries for the RabbitMQ user:
This configuration sets both the soft and hard limits to 65536, where soft is the limit RabbitMQ is bound by under normal operations, and hard is the maximum limit that can be set by the application with setrlimit.
Setting Limits in systemd
If RabbitMQ is run as a service under systemd, you might prefer setting the limits directly in the service definition:
- Locate the service unit file, which might be at
/etc/systemd/system/rabbitmq-server.serviceor/usr/lib/systemd/system/rabbitmq-server.service. - Add or modify the
LimitNOFILEdirective:
- Reload the systemd configurations and restart the RabbitMQ service:
Verification
After updating the limits, verify them by checking the RabbitMQ status again with rabbitmqctl status and ensure the file_descriptors count reflects the updated values.
Troubleshooting Common Issues
Even after increasing file descriptors, issues might persist if:
- Misconfiguration: Incorrect files edited, typos, or wrong user limits.
- Permission Issues: RabbitMQ process does not have the necessary permissions to apply new limits.
- Reaching Other Limits: TCP port exhaustion, memory constraints, or other limits might mimic file descriptor issues.
Summary Table
| Context | Method | Configuration Files/Commands | Considerations |
| System-wide | limits.conf | /etc/security/limits.conf | Requires logout/login or reboot. Applies to all processes launched by the RabbitMQ user. |
| System service (systemd) | Direct service configuration | Edit LimitNOFILE in systemd service file | Requires reloading systemd and restarting the service. Specific to the service only. |
| Verification | RabbitMQ and system commands | rabbitmqctl status, ulimit -n | Confirm the changes are in effect and sufficient. |
Deploying RabbitMQ with properly configured file descriptor limits is crucial for handling high loads and ensuring stable and efficient message brokering. As system environments and specific deployments might vary, always consider additional adjustments and monitoring to optimize RabbitMQ performance.

