title: Nginx: [emerg] socket() failed (24: Too many open files)
body: <p>I could see lot more thread created for this issue. Tried all the solutions mentioned on those threads. But None of the options worked for me. So I'm creating this new thread.</p>
  
  <blockquote>
    <p>OS : CentOS 7.2.1511</p>
    
    <p>Nginx : 1.10.0</p>
  </blockquote>
  
  <p>Error message:</p>
  
  <pre><code>Nov  2 23:21:36 localhost nginx: Starting nginx: nginx: [emerg] socket() x.x.x.x:80 failed (24: Too many open files)
  Nov  2 23:21:36 localhost nginx: [FAILED]
  Nov  2 23:21:36 localhost systemd: nginx.service: control process exited, code=exited status=1
  Nov  2 23:21:36 localhost systemd: Failed to start SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server.
  Nov  2 23:21:36 localhost systemd: Unit nginx.service entered failed state.
  Nov  2 23:21:36 localhost systemd: nginx.service failed.
  </code></pre>
  
  <p>Ulimit Value:</p>
  
  <pre><code>[root@serv1 nginx]# ulimit -n
  16000
  [root@serv1 nginx]# 
  </code></pre>
  
  <p>Sysctl.conf:</p>
  
  <pre><code>fs.file-max = 752415
  </code></pre>
  
  <p>nginx.conf:</p>
  
  <pre><code>worker_rlimit_nofile 30000;
  </code></pre>
  
  <p>nginx user Ulimit:</p>
  
  <pre><code>[nginx@serv1 ~]$ ulimit -Sn
  16000
  [nginx@serv1 ~]$ ulimit -Hn
  16000
  [nginx@serv1 ~]$ 
  </code></pre>
  
  <p>Nginx PID max Open files limit:</p>
  
  <pre><code>Max open files            1024                 4096                 files
  </code></pre>
  
  <p>Not sure, why the open files limit is not reflected to nginx process. when I checked the pid limit value from proc directory. It shows default value as mentioned above. Values should be 16000 for both soft &amp; hard limits.</p>
  
  <p>Also, I checked the openfiles limit on the server for nginx process. it does not go above 1042.</p>
  
  <p>openfiles :</p>
  
  <pre><code>[root@serv1 ~]# ps -ef | grep nginx
  root      4285     1  0 23:12 ?        00:00:00 nginx: master process /usr/sbin/nginx -c /etc/conf/nginx/nginx.conf
  nginx     4286  4285  0 23:12 ?        00:00:00 nginx: worker process
  root      4308  4290  0 23:12 pts/1    00:00:00 grep --color=auto nginx
  [root@serv1 ~]# lsof -p 4285 | wc -l 
  1042
  [root@serv1 ~]# 
  </code></pre>
  
  <p>Someone please help me to fix this problem. Thanks.</p>