• Skip to main content
  • Skip to primary sidebar
  • Home
  • WordPress
  • web Hosting
  • linux
  • mysql
  • nginx
  • apache2
  • devops

Raju Ginni

wordpress tutorials seo hosting etc

You are here: Home / Linux sysadmin tutorials linux system administrator / increase open file limit linux File descriptor ft nginx , mysql, lemp

increase open file limit linux File descriptor ft nginx , mysql, lemp

 

  1. System level file limit
  2. User level limit
  3. process level limit

1024 by default

Every connection   / process need to open at least 2 files,

 

Nginx active connection 524  -1024 by default for core.

1024*4 = 4080  active connections at least needed 8160 open file limit.

 

Table of Contents

Toggle
  • how to Check File descriptor limit per process Linux
  • checking open file with ulimit command
  • How to check systemwide open file limit
  • Check maximum process limit for user
  • increase process limit for user linux
  • increase open file limits for User command line with ulimit
  • Shared servers inode  limit
  • nginx check open file limit
  • Setting Open file limit nginx conf
  • Increasing root user open file limits not working
    • SSHD Configuration file USE PAM = YES
  • PAM limit module pam_limits.so

how to Check File descriptor limit per process Linux

cat /etc/security/limits.conf

* soft nofile 1024000
* hard nofile 1024000
* soft nproc 640000
* hard nproc 640000
root soft nproc 1000000
root soft nproc 100000
root soft nofile 100000
root hard nofile 100000

 

(*) means any user it could be nginx, mysql, php, redis etc

nproc = number of process  (generally 2x of nofile)

nofile = number of open file

checking open file with ulimit command

root@localhost:~# ulimit -Sn
1024
root@localhost:~# ulimit -Hn
524288

H hard limits

S soft limits

we can raise soft limits upto hard limit.

 

 

How to check systemwide open file limit

root@localhost:~# cat /proc/sys/fs/file-max
2097152

10% memory

Check maximum process limit for user

so need at least 2 open files for 1 process.

root@localhost:~# ulimit -H -u
31498
root@localhost:~# ulimit -S -u
31498

increase process limit for user linux

first login as user,

sudo su mysql

ulimit -u 50000

root@localhost:~# ulimit -S -u
50000

increase open file limits for User command line with ulimit

-n (open files): 64000
-u (processes/threads): 64000

before

root@localhost:~# ulimit -Sn
1024

ulimit -n 100000

after

root@localhost:~# ulimit -n 100000
root@localhost:~# ulimit -Sn
100000

root@localhost:~# ulimit -Hn
100000

/ until restart only

 

Shared servers inode  limit

150000

inode = number files in a hard disk or per account in shared hosting account to limit the unlimited disk space.

nginx check open file limit

cat /proc/{nginx-master-process-id}/limits

{nginx-master-process-id}

getting a nginx process ID

top -u nginx

ps aux | grep nginx

root 2950 0.0 0.1 232192 11544 ? Ss Jun01 0:00 nginx: master

 

cat /proc/2950/limits

Max open files

soft: 1024

hard 524288

Max processes 31498

Here every

Setting Open file limit nginx conf

Nginx: 24: Too Many Open Files Error And Solution

/etc/security/limits.conf
nginx soft nofile 10000
nginx hard nofile 30000
reload systcl
sysctl -p

nano /etc/nginx/nginx.conf

 

worker_rlimit_nofile 4096;

add this in nginx conf

restart or reload not kills nginx master process

other ways

edit the  /lib/systemd/system/nginx.service

centos has different approach

/etc/security/limit.conf is used by PAM, so it shoud be nothing to do with www-data (it’s nologin user).

 

Increasing root user open file limits not working

root@localhost:~# ulimit -Sn
1024

root@localhost:~# ulimit -Hn
524288

(most systems do not allow this value to be set)

root@localhost:~# more /etc/systemd/system.conf | grep NOFILE
#DefaultLimitNOFILE=1024:524288

nano /etc/systemd/system.conf

DefaultLimitNOFILE=10024:524288

edit the above file

/etc/systemd/user.conf (may be required)

nano /etc/systemd/user.conf

nothing apperaed like above. ubuntu 20.04

 

SSHD Configuration file USE PAM = YES

this allows to ssh session to use pam limit

root@localhost:~# ulimit -n
100000

but nginx still at 1024 until it restarts, started as root

 

PAM limit module pam_limits.so

limits.conf –

is configuration file for the pam_limits module

 

 

nano /etc/pam.d/common-session

A reboot will show the limits

Appending the line *

for RHEL / centos / Fedora

nano /etc/pam.d/login

session required pam_limits.so

 

 

also mo0re about /etc/security/limit.conf file

Primary Sidebar

Linux sysadmin tutorials linux system administrator

  • top 10 apt & apt-get commands (most used) apt vs apt-get
  • If-Else Statements in Shell Scripting
  • linux commands pdf (files & Directories, zip & unzip process, search etc)
  • Find Files with Specific Text on Linux grep find command
  • linux performance tuning inode limit file descriptors tco, kernel etc
  • Variables and Data Types in Shell Scripting
  • Top 10 most used Cat commands with examples (create, view, append files)
  • Ip tables / ufw / firewall d commands for block port ip rate limiting
  • Top 10 zip / tar commands to compress & extract files in linux
  • TOP 10 mv & cp commands in linux to move & copy files in Linux
  • Top 10 GREP Commands in linux to search files directory words strings
  • lsof netstat commands to know listening ports in linux 3 ways
  • Upgrade Ubuntu from 18.04 (19.10) to 20.04 LTS command line or gui server | desktop
  • 3 Ways (SCP, rsync, Sftp) linux server migration between two remote server apache nginx
  • linux system specs commands (CPU, Memory, Disk )speed, type. manufacture
  • linux sysctl command tweaks & hardening
  • linux security limits.conf deciding user limits process limits for nginx server
  • ulimit linux unlimited command unlimto set & know user limits open files file descriptor max user process etc.
  • red hat linux certification cost jobs salary syllabus courses fees
  • ufw firewall commads allow port enable disable ubuntu 20.04
  • ddos attack prevention
  • change ssh port in linux - avoid sshd ddos attacks
  • ping command
  • memcached install ubuntu wordpress
  • check linux version (lsb_release -a) ubuntu debian 32 or 64 bit
  • rsync command linux with examples comparison to scp
  • how to uninstall package in linux ubuntu rpm, yum apt-get
  • increase open file limit linux File descriptor ft nginx , mysql, lemp
  • remove repository ubuntu
  • htop commad memory details virtual vs shard vs resident
  • chown command in Linux with Examples
  • Kill PHP process
  • VIrtual Memory vs RSS Memory vs Shared memory in Linux
  • oom killer fixing it by configuration linux ubuntu
  • Install Lemp nginx mysql php fpm Stack on Debian 11 with repository
  • connect two remote servers linux command line
  • auto start after oom killer Mysql & php fpm nginx etc ubuntu wth systemd or cron job
  • load average Linux 1, 5, 15 min 2,4,8 cores explained
  • Control Structures in Shell Scripting
  • Shell Scripting Roadmap for Beginners to Advanced
  • awk commands with practical examples
  • Shell Scripting Tutorial for Beginners 🚀
  • find Command in Linux with Examples
  • sed Command in Linux with Examples (Beginner to Advanced)
  • Linux Text processing commands in with Examples
  • linux disk management commands
  • fdisk command in linux with examples
  • how to add a new disk in linux
  • Linux mount Command with Examples
  • fstab options with examples
  • Top 50 Shell Scripting Interview Questions and Answers
  • Linux Networking Interview Questions and Answers
  • Linux Networking Commands Cheat Sheet with Examples pdf
  • Netstat & SS Commands cheat sheet with examples Interview Questions
  • Nmap Cheat Sheet – Network Scanning & Security
  • Bash Brackets ([], (), {}, $( ), $(( ))) – Types, Uses & Examples

hi i am raju ginni, primalry i manage wordpress websites on GCP cloud platform as a cloud engineer, and create content on passionate things.
you can follow me on youtbe

© 2025 - All Rights Reserved Disclaimer & Privacy Policy