Monday, 2 May 2011

nginx, rails and ubuntu - 502 bad gateway

We were getting tons of 502 errors under load, but then I stumbled across a posting in a news group.

cat /proc/sys/net/core/somaxconn

Will show you how many connections you can have. This should be 1024, because Phusion Passenger is hard coded for this value. Mine was 128!

Do this:
sudo sysctl -w net.core.somaxconn=1024

And then restart nginx.

1 comment:

Phil said...

To make this change permanent you need to add


With this value.