Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

So I am trying to set up Nginx with uwsgi for my Django app.

Here is my /etc/nginx/nginx.conf file:

# /etc/nginx/nginx.conf
user       richard richard;  ## Default: nobody
worker_processes  5;  ## Default: 1
error_log  /var/log/nginx/error.log;
pid        /var/log/nginx/nginx.pid;
worker_rlimit_nofile 8192;

events {
  worker_connections  4096;  ## Default: 1024
}

http {
  include   /etc/nginx/mime.types;
  include   /etc/nginx/proxy.conf;
  index     index.html index.htm;

  default_type application/octet-stream;
  log_format   main '$remote_addr - $remote_user [$time_local]  $status '
    '"$request" $body_bytes_sent "$http_referer" '
    '"$http_user_agent" "$http_x_forwarded_for"';
  access_log   /var/log/nginx/access.log  main;
  sendfile     on;
  tcp_nopush   on;
  server_names_hash_bucket_size 128; # this seems to be required for some vhosts

  include   /etc/nginx/conf.d/vhost.conf;
}

And my /etc/nginx/conf.d/vhost.conf:

# /etc/nginx/conf.d/vhost.conf
upstream django {
  # connect to this socket
  server unix:///tmp/uwsgi.sock;
}

server {
  # the port your site will be served on
  listen      80;
  # the domain name it will serve for
  server_name localhost;
  charset     utf-8;

  client_max_body_size 2M;

  location /media  {
    alias /usr/local/django-app/media;
  }

  location /static {
    alias /usr/local/django-app/static;
  }

  # finally, send all non-media requests to the Django server.
  location / {
    uwsgi_pass  django;
    include     /etc/nginx/uwsgi_params;
  }
}

When I go to localhost I get:

Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:80... connected
HTTP request sent, awaiting response... 502 Bad Gateway
2013-12-22 03:08:56 ERROR 502: Bad Gateway

Any ideas?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Your Django app is not running. Start it (and make sure you got the socket path correct).

share|improve this answer

Your Answer

 
discard

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.