Nginx start issue in production mode


I recently upgraded to version 12 and migrated my custom app. Everything worked well in developer mode, and I was able to use my custom site via the browser as expected. As soon as I switched to production mode I started experiencing issues with the web server (nginx). When I switch to production using:

sudo bench setup production

, I get the following output and errors:

frappe@ip-10-0-0-74:~/frappe-bench$ sudo bench setup production frappe
supervisor.conf already exists and this will overwrite it. Do you want to continue? [y/N]: y
Port configuration list:

Site erpnext.local assigned port: 80

Site iams.logikal assigned port: 8001
nginx.conf already exists and this will overwrite it. Do you want to continue? [y/N]: y
INFO:bench.utils:sudo /usr/bin/supervisorctl reread
No config updates to processes
INFO:bench.utils:sudo /usr/bin/supervisorctl update
nginx: [emerg] duplicate upstream “frappe-bench-frappe” in /etc/nginx/sites-enabled/frappe.conf:1
nginx: configuration file /etc/nginx/nginx.conf test failed
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 11, in
load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
File “/home/frappe/bench-repo/bench/”, line 40, in cli
File “/home/frappe/.local/lib/python3.6/site-packages/click/”, line 764, in call
return self.main(*args, **kwargs)
File “/home/frappe/.local/lib/python3.6/site-packages/click/”, line 717, in main
rv = self.invoke(ctx)
File “/home/frappe/.local/lib/python3.6/site-packages/click/”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/.local/lib/python3.6/site-packages/click/”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/.local/lib/python3.6/site-packages/click/”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/frappe/.local/lib/python3.6/site-packages/click/”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/frappe/bench-repo/bench/commands/”, line 67, in setup_production
setup_production(user=user, yes=yes)
File “/home/frappe/bench-repo/bench/config/”, line 41, in setup_production
File “/home/frappe/bench-repo/bench/config/”, line 141, in reload_nginx
subprocess.check_output([‘sudo’, find_executable(‘nginx’), ‘-t’])
File “/usr/lib/python3.6/”, line 356, in check_output
File “/usr/lib/python3.6/”, line 438, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command ‘[‘sudo’, ‘/usr/sbin/nginx’, ‘-t’]’ returned non-zero exit status 1.

If try and restart nginx, I get the following output:

frappe@ip-10-0-0-74:~/frappe-bench$ sudo service nginx restart Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

and when checking the status of the service, I get:

frappe@ip-10-0-0-74:~/frappe-bench$ systemctl status nginx.service ● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Mon 2019-10-07 10:57:16 UTC; 1min 48s ago Docs: man:nginx(8) Process: 5143 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/ (code=exited, status=0/SUCCESS) Process: 5044 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Process: 5269 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE) Main PID: 5048 (code=exited, status=0/SUCCESS)

I’m going around in circles with this and have not found a resolution. Any help to resolve it would be appreciated.

You seem to have two sites here - you need to identify which one is valid and best delete references to the one that is superfluous?

Thanks for the replies.

I tried the following:

 sudo unlink /etc/nginx/conf.d/frappe-bench.conf
 bench setup nginx
 sudo service nginx start
 bench use iams.logikal

The service now appears to start ok, and I can acces the default-generated erpnext web page (on port 80), but cannot access my custom site (at the assigned port 8001; I get a connection timeout after about a minute)

clarkej, I thought I could have a multitenant configuration, as per these instructions? Is that not the case? If not what do I need to do to restrict production to my custom site only.


A closed port or firewall may explain your timeout issue.

Inspect frappe-bench/logs/* and /var/log/nginx/* to identify what is going on.


Thanks clakej! That’s exactly it. The port was blocked.


Hurray I shy away from multitenant!

facing same problem. can you please help with solution.