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

I have a very low traffic site running on nginx, with 4 workers, 1024 connections each.

Every several hours I start seeing in the error log "1024 worker_connections are not enough", and my site slows down / becomes flakey. A nginx restart solves the problem entirely for the next several hours.

Clearly something odd is happening, there is no way I'm serving 4k concurrent users of my application.

Other than looking at the access log (which looks normal), is there a way to observe with greater details what nginx is doing?

Is there some notorious configuration combination that might result in old connections being held open and not closed?


edit this looks not right

# lsof |grep nginx |grep CLOSE_WAIT |wc -l
share|improve this question
are you using proxypass? – Dan R Dec 4 '10 at 0:56
Nope, I'm not using any kind of proxy setup. It's a rails site on passenger. – John Bachir Dec 4 '10 at 2:29
Maybe try enabling that to see which requests this happens with. I'm not familiar with passenger / rails. If this is on the port connecting to web clients, the client has closed the connection but nginx hasn't closed on its side. – Dan R Dec 4 '10 at 3:29
up vote 6 down vote accepted

Without proxy pass / reverse proxy

max_clients = worker_processes * worker_connections

With reverse proxy

max_clients = (worker_processes * worker_connections ) / (X * 2)

2 is because you open a connection to what you are proxying

X is however many concurrent connections these clients make to you

To see which connections are hanging around you could run lsof -i :PORT. It will show all connections open to nginx, and their state.

share|improve this answer
trying that… lsof 4.81 on Ubuntu… "illegal option character: I" – John Bachir Dec 4 '10 at 2:31
see lsof output in edit above – John Bachir Dec 4 '10 at 2:38
didn't mean to capitalize the -i – Dan R Dec 4 '10 at 3:18
lsof was very useful, thanks! – John Bachir Dec 4 '10 at 21:57

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.