Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

Our server is showing a lot of 500 internal error pages for random requests. We know the app is working because our code is unit tested. The server setup is Nginx with Unicorn running a single Rails apps on an Ubuntu 10.4 LTS.

As far as we can tell the requests fail before they are passed to the Unicorn because there are no log entries in Unicorn's log file or our Airbrake (another logging service we are using), but the Nginx's log file does show the 500 status entries. The server is under normal load so it's not running out of RAM or anything.

The Nginx error.log file isn't really giving us anything useful. There are no entries that suggest file issues or resource problems.

How should I go on about finding the issue?


Here is our nginx config for the site:

# This is the socket that unicorn listens to
upstream unicorn {
        server unix:/tmp/unicorn.sock;

server {
  listen 80;
  client_max_body_size 10m;
  root /var/www/current/public;
  access_log  /var/log/nginx/access.log;
  error_page 500 502 503 504 /var/www/shared/500.html;

  if ($http_user_agent ~* (majestic12|easou|Sogou|baidu|ahrefs) ) {
    return 403;

  location / {
#    auth_basic "Restricted";
#    auth_basic_user_file /var/www/shared/.htpasswd;
    proxy_set_header  X-Real-IP  $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_max_temp_file_size 0;

    if (-f $request_filename) {
    if (-f $document_root/system/maintenance.html) {
      rewrite  ^(.*)$  /system/maintenance.html last;
    if (-f $request_filename/index.html) {
      rewrite (.*) $1/index.html break;
    if (-f $request_filename.html) {
      rewrite (.*) $1.html break;

   if (!-f $request_filename) {
      proxy_pass http://unicorn;
share|improve this question
First you look at the nginx error log. – Michael Hampton Mar 4 '13 at 0:25
@MichaelHampton yes have looked but there really isn't much that points to anything useful. Just a few error in the config file which we have corrected – Roman Mar 4 '13 at 0:33
If you're unwilling to share anything with us, then there's nothing we can do for you. – Michael Hampton Mar 4 '13 at 0:53
Sorry didn't mean to hold back. What would you like to see? – Roman Mar 4 '13 at 1:03
As I already said, the nginx error log. – Michael Hampton Mar 4 '13 at 1:36

If you have nothing in rails error logs, it probably is HTTP error 503 (unavailable backend) or 504 (backend timeout). Exact error and cause will be in nginx error log. Both of errors are because unicorn cannot serve all HTTP requests.

You can do few things:

  • increase worker_processes in unicorn.rb
  • increase proxy_read_timeout in nginx.conf
  • add second unicorn server and load balance between two by adding it in upstream unicorn
share|improve this answer

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.