Question

[emerg] duplicate upstream "app_server" in /etc/nginx/sites-enabled/<project_name>:1

  • Posted on January 22, 2015
  • HHHAsked by HHH

I’m following this tutorial by @asb. But i got this error when I try restart nginx:

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

The test-django file in etc/nginx/site-available/ :

upstream app_server {
    server 127.0.0.1:9500 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 www.mydomain.com;

    keepalive_timeout 5;

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

    # your Django project's static files - amend as required
    location /static {
        alias /home/django/test-django/cmsh/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;
    }
}

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Never mind this fix the error:

cd  /etc/nginx/sites-enabled/

sudo rm -r test-django

sudo service nginx restart

 * Restarting nginx nginx    

and my test-django looks like this now:

upstream app_server {
    server 127.0.0.1:9500 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 www.mydomain.com;

    keepalive_timeout 5;

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

    # your Django project's static files - amend as required
    location /static {
        alias /home/django/test-django/cmsh/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;
    }
}

‘default_server’ were deleted

source