I'm getting this error:

nginx: [emerg] duplicate upstream "app_server" in /etc/nginx/sites-enabled/django.save:1

this is my config file:

upstream app_server {
    server fail_timeout=0;

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.html index.htm;

    client_max_body_size 4G;
    server_name _;

    keepalive_timeout 5;

    # Your Django project's media files - amend as required
    location /media  {
        alias /home/django/django_project/django_project/media;

    # your Django project's static files - amend as required
    location /static {
        alias /home/django/django_project/django_project/static; 

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://app_server;

1 Answer 1


I figured it out:

cd  /etc/nginx/sites-enabled/

sudo rm -r django.save

sudo service nginx restart

 * Restarting nginx nginx                                                [ OK ]
  • I know what happened. You backed up your config in the .save file. Nginx does not care what your file is called, it just executes every file in that folder. So when it came across second config file configuring the same port, it complained.
    – look
    Oct 15, 2014 at 20:27
  • In my case, the cause was another nginx config file that declared upstream app_server { ... }. (We all copied from the same examples to start.) The solution was to rename "app_server" to something else.
    – jma
    May 5, 2015 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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