Tuesday, July 31, 2012

nginx: Too many open files

if you have error:
socket() failed (24: Too many open files)

you need change  worker_rlimit_nofile in nginx.conf . (Default: 1024)


#cat  /etc/nginx/nginx.conf
user www-data;
worker_processes 1;

error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;


worker_rlimit_nofile 4096; ### default is 1024


events {
worker_connections 1024;
# multi_accept on;
}





than restart (reload) nginx  /etc/init.d/nginx restart



and check :


#ps waux|grep nginx
   root 2604 0.0 0.0 9252 908 pts/0 S+ 09:53 0:00 grep --color=auto nginx
   root 3330 0.0 0.2 113516 40324 ? Ss Jul26 0:00 nginx: master process /usr/sbin/nginx
   www-data 18098 0.7 0.2 113516 40168 ? S Jul30 10:35 nginx: worker process


#cat /proc/18098/limits |grep files
  Max open files 4096 4096 files  



No comments: