Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can someone explain why "ulimit" before starting Nginx?

ulimit -SHn 51200
share|improve this question

migrated from May 27 '11 at 5:21

This question came from our site for pro webmasters.

Nginx consumes a lot of sockets. It's a single-process web server (well, you may run several "worker" instances, but basically all of them behave like a single-process web-server) and is able to accept many connections (each of them consuming a socket) and proxy to many backends (each connections consumes a socket again). Thus, Nginx can easily excess a default limit of 1024 file descriptors per process. Which means, there is a need to increase this limit for Nginx, thus ulimit.

share|improve this answer

ulimit is a *nix command that places limits on resources. Alaz gives a good explanation that Nginx can easily exceed the default limit of 1024 file descriptors. It is necessary to raise this limit thru the ulimit command in order to have Nginx run the way you want it to.

ulimit -SHn 51200 limits the number of open file descriptors to 51200.

Here's the breakdown of your ulimit command:
-S --> use the soft resource limit
-H --> use the hard resource limit
-n --> the maximum number of open file descriptors

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.