bench.exceptions.CommandFailedError: supervisorctl restart frappe:

Why is this error occurring when I give bench restart. the previous thing was I was installing erpnext after that I had to restart and I am getting this.

Hi @Thaya_Govzig:

bench restart just works in production environment …

If your bench is running, stop in console with Ctrl+c … Maybe you closed your console and running bench is not “visible”. Take a look here:

Hope this helps.

Looks like they’re in production. That script on the previous answer is for development.

This is most likely a permission issue or just bad config

Try redoing the production setup

sudo bench setup production yourusername

You can run it twice to be sure


Hi @adam26d:

My answer is based on previous @Thaya_Govzig topic thread (When bench start is given this shows - #7 by Thaya_Govzig) so I guess they are not still in production :wink: I don’t really know.

I think bench restart causes exactly this error if you try it in development mode.

Btw, seems you are the creator of . Many thanks, made my day every day :joy: :joy:


It was a community effort that keeps giving :grin::grin:

what’s the reason for this

Installing erpnext…
An error occurred while installing erpnext: (‘Module Def’, ‘Accounts’, IntegrityError(1062, “Duplicate entry ‘Accounts’ for key ‘PRIMARY’”))
Traceback (most recent call last):
File “apps/frappe/frappe/model/”, line 532, in db_insert
File “apps/frappe/frappe/database/”, line 217, in sql
self._cursor.execute(query, values)
File “env/lib/python3.11/site-packages/pymysql/”, line 153, in execute
result = self._query(query)
File “env/lib/python3.11/site-packages/pymysql/”, line 322, in _query
File “env/lib/python3.11/site-packages/pymysql/”, line 558, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “env/lib/python3.11/site-packages/pymysql/”, line 822, in _read_query_result
File “env/lib/python3.11/site-packages/pymysql/”, line 1200, in read
first_packet = self.connection._read_packet()
File “env/lib/python3.11/site-packages/pymysql/”, line 772, in _read_packet
File “env/lib/python3.11/site-packages/pymysql/”, line 221, in raise_for_error
File “env/lib/python3.11/site-packages/pymysql/”, line 143, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.IntegrityError: (1062, “Duplicate entry ‘Accounts’ for key ‘PRIMARY’”)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “apps/frappe/frappe/commands/”, line 462, in install_app
_install_app(app, verbose=context.verbose, force=force)
File “apps/frappe/frappe/”, line 294, in install_app
add_module_defs(name, ignore_if_duplicate=force)
File “apps/frappe/frappe/”, line 633, in add_module_defs
d.insert(ignore_permissions=True, ignore_if_duplicate=ignore_if_duplicate)
File “apps/frappe/frappe/model/”, line 295, in insert
File “apps/frappe/frappe/model/”, line 559, in db_insert
raise frappe.DuplicateEntryError(self.doctype,, e)
frappe.exceptions.DuplicateEntryError: (‘Module Def’, ‘Accounts’, IntegrityError(1062, “Duplicate entry ‘Accounts’ for key ‘PRIMARY’”))

when I use the command " Bench -site install-app erpnext

Hi @Thaya_Govzig:

This happened because your previous app installation process has not been finished properly.
Check this video from Geoffrey Karani:

Please open separate topic for this question next time :slight_smile:
Hope this helps.