SysTutorials

Increase the Maximum Open Files Limit on Linux

· updated April 12, 2026

When you hit the open files limit on Linux, you’ll see errors like “Too many open files” — typically when running applications that create many temporary file handles. The default limit is often 1024, which isn’t enough for resource-heavy workloads.

Check your current limit:

ulimit -n

Understanding soft and hard limits

Linux maintains two types of file descriptor limits:

The kernel also has a system-wide limit you can check:

cat /proc/sys/fs/file-max

Setting limits in /etc/security/limits.conf

The persistent way to change limits is through /etc/security/limits.conf. This file is read by PAM (Pluggable Authentication Modules) at login.

Edit the file:

sudo nano /etc/security/limits.conf

Add these lines at the end (before any @include statements):

*                soft   nofile           65536
*                hard   nofile           65536

The * applies to all users. To set limits for a specific user:

username       soft   nofile           65536
username       hard   nofile           65536

Or for a group:

@groupname     soft   nofile           65536
@groupname     hard   nofile           65536

Changes take effect on next login. Test with a new shell session:

ulimit -n

Setting limits for specific services

For systemd services, use the LimitNOFILE directive in the service file or drop-in directory:

sudo mkdir -p /etc/systemd/system/myservice.service.d

Create /etc/systemd/system/myservice.service.d/limits.conf:

[Service]
LimitNOFILE=65536

Then reload and restart:

sudo systemctl daemon-reload
sudo systemctl restart myservice

Temporary limits (current session only)

To change the limit for your current shell only:

ulimit -n 65536

This doesn’t persist after logout.

Other commonly adjusted limits

While you’re configuring limits, you may need to adjust related settings:

*                soft   nproc            4096
*                hard   nproc            4096
*                soft   memlock          unlimited
*                hard   memlock          unlimited

System-wide kernel limits

For high-traffic servers, you may also need to increase the kernel-level limit:

sudo sysctl fs.file-max=2097152

To make this permanent, add it to /etc/sysctl.conf:

fs.file-max=2097152

Then apply:

sudo sysctl -p

Choosing the right value

Common recommendations:

Monitor actual usage with:

lsof -u username | wc -l

Or check system-wide:

cat /proc/sys/fs/file-nr

This shows: <used> <unused> <max>. If used is consistently near max, increase the limit further.

Verify limits are applied

After making changes, verify with a fresh login:

ulimit -a

This shows all resource limits for your session.

2026 Best Practices and Advanced Techniques

For Increase the Maximum Open Files Limit on Linux, understanding both the fundamentals and modern practices ensures you can work efficiently and avoid common pitfalls. This guide extends the core article with practical advice for 2026 workflows.

Troubleshooting and Debugging

When issues arise, a systematic approach saves time. Start by checking logs for error messages or warnings. Test individual components in isolation before integrating them. Use verbose modes and debug flags to gather more information when standard output is not enough to diagnose the problem.

Performance Optimization

Security Considerations

Security should be built into workflows from the start. Use strong authentication methods, encrypt sensitive data in transit, and follow the principle of least privilege for access controls. Regular security audits and penetration testing help maintain system integrity.

These complementary tools expand your capabilities:

Integration with Modern Workflows

Consider automation and containerization for consistency across environments. Infrastructure as code tools enable reproducible deployments. CI/CD pipelines automate testing and deployment, reducing human error and speeding up delivery cycles.

Quick Reference

This extended guide covers the topic beyond the original article scope. For specialized needs, refer to official documentation or community resources. Practice in test environments before production deployment.

← All posts