[Django]-Ngnix – duplicate upstream "app_server" in /etc/nginx/sites-enabled/django

14👍

If you have other configuration files in the directory(/etc/nginx/sites-enabled/django) with same upstream name as ‘app_server ‘ then you get that duplicate upstream error.

So replace ‘app_server’ to any other name. run nginx -t to check for any errors, then restart nginx,

1👍

If you tape in your terminal cat /etc/nginx/nginx.conf
you will see these two lines:

include /etc/nginx/conf.d/*.conf;

Wich means Nginx load all files .conf (for example if you are using dokku to deploy your app, you will see dokku.conf which contain "include /home/dokku/*/nginx.conf;" itself) and this means loading all /home/dokku/whatever-folder/nginx.conf

include /etc/nginx/sites-enabled/*;
👤Zicrou

1👍

If the same upstream name "app_server" is not found, find the same upstream name with different case,like:

upstream app_server {
  server 127.0.0.1:9000
}
upstream App_server {
  server 127.0.0.1:9000
}

This may also cause conflicts. It may be the setting of nginx, but I haven’t found the document yet

0👍

This problem came up in my case because my configuration file was in /etc/nginx/conf.d and I also had a symbolic link to it in /etc/nginx/sites-enabled/. Not sure how nginx loads the files but apparently it was loaded twice. No matter what name I chose for the upstream, I got duplicate error. Deleting symbolic link fixed the problem.

Leave a comment