[Guide] How to install ERPNext v14 on Linux Ubuntu (step-by-step instructions)

You can force install an app with bench install-app hrms --force

Just wanted to say thanks very much for this! I tried DigitalOcean’s 2020 tutorial twice but kept having issues with all their complex extra command steps… Was very straight forward and easy to follow if you’ve setup a web server before.

how to get education app?

Hi @GhadaEbrahim to get any app you just need to run the bench get-app and then then bench install-app commands. For eg. to get education app you can run the following:

bench get-app education
bench --site yoursitename.com install-app education

For more details check the official repo here: GitHub - frappe/education

After initiating frappe I am having some waring “WARN: restart failed: Couldn’t find supervisorctl in PATH”

Any one know what to do?

I have tried to install with this waring I was successfully install erpnext.

You must not complete the setup wizard before installing erpnext app.

Once you perform setup wizard, erpnext app cannot be installed.

I get the same error too with hrms app.

However I also get an error when installing payments app:

An error occurred while installing payments: 'CustomField' object has no attribute 'is_virtual'

My problem was to UPGRADE a site, instead of installing a new site. I do this then it works:

bench --verbose --site SITE_NAME migrate

Then you can:

bench --verbose --site SITE_NAME install-app hrms

Hope this helps

All this was working fine until 90 days were over. The certificate seemed to renew it self but after a huge trouble I learnt that we had to run this line after 90 days to keep the web application running on https.

sudo certbot --nginx

Is there any way to automate this ?

Here is how I sorted the error

pymysql.err.OperationalError: (1698, “Access denied for user ‘root’@‘localhost’”)

while creating the site by running command

bench new-site site1.local

I also faced following error. Following is my full terminal message trail.

frappe@erpnext14-ubuntu22041:~/frappe-bench$ bench new-site site1.local
MySQL root password: 
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 109, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 74, in new_site
    _new_site(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 80, in _new_site
    install_db(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 156, in install_db
    setup_database(force, source_sql, verbose, no_mariadb_socket)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/__init__.py", line 20, in setup_database
    return frappe.database.mariadb.setup_db.setup_database(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/setup_db.py", line 41, in setup_database
    if force or (db_name not in dbman.get_database_list()):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/db_manager.py", line 49, in get_database_list
    return self.db.sql("SHOW DATABASES", pluck=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 199, in sql
    self.connect()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 113, in connect
    self._conn = self.get_connection()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 98, in get_connection
    conn = self._get_connection()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 104, in _get_connection
    return self.create_connection()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 107, in create_connection
    return pymysql.connect(**self.get_connection_settings())
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 353, in __init__
    self.connect()
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 633, in connect
    self._request_authentication()
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 907, in _request_authentication
    auth_packet = self._read_packet()
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 725, in _read_packet
    packet.raise_for_error()
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1698, "Access denied for user 'root'@'localhost'")

When I tried to uninstall the site with command bench drop-site site1.local , I again got the error as below:

Taking backup of site1.local
================================================================================
Error: The operation has stopped because backup of site1.local's database failed.
Reason: (1045, "Access denied for user '_c6a99b789ee42f7a'@'localhost' (using password: YES)")

Fix the issue and try again.
Hint: Use 'bench drop-site site1.local --force' to force the removal of site1.local
frappe@erpnext14-ubuntu22041:~/frappe-bench$ bench drop-site site1.local --force
Taking backup of site1.local
Dropping site database and user
MySQL root password: 
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 109, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 832, in drop_site
    _drop_site(site, db_root_username, db_root_password, archived_sites_path, force, no_backup)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 870, in _drop_site
    drop_user_and_database(frappe.conf.db_name, db_root_username, db_root_password)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/__init__.py", line 37, in drop_user_and_database
    return frappe.database.mariadb.setup_db.drop_user_and_database(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/setup_db.py", line 86, in drop_user_and_database
    dbman.drop_database(db_name)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/db_manager.py", line 30, in drop_database
    self.db.sql_ddl(f"DROP DATABASE IF EXISTS `{target}`")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 363, in sql_ddl
    self.commit()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 999, in commit
    self.sql("commit")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 199, in sql
    self.connect()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 113, in connect
    self._conn = self.get_connection()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 98, in get_connection
    conn = self._get_connection()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 104, in _get_connection
    return self.create_connection()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 107, in create_connection
    return pymysql.connect(**self.get_connection_settings())
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 353, in __init__
    self.connect()
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 633, in connect
    self._request_authentication()
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 907, in _request_authentication
    auth_packet = self._read_packet()
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 725, in _read_packet
    packet.raise_for_error()
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1698, "Access denied for user 'root'@'localhost'")

Even using –force didn’t help. Then I referred the official documentation and used following command to create site and it successfully created site. But note that before running command, I manually deleted the site folder /home/frappe/frappe-bench/sites/site1.local

bench new-site site1.local --db-name erpnext --db-password password --db-root-username frappe --db-root-password password --admin-password password

I actually used the userid and password that i created while installing mariadb. my mariadb server admin user was frappe and password is password. This is apart from the root user that gets automatically created while installing mariadb.

And following is the message trail in my terminal:

frappe@erpnext14-ubuntu22041:~/frappe-bench$ bench new-site site1.local --db-name erpnext --db-password password --db-root-username frappe --db-root-password password --admin-password password

Installing frappe...
Updating DocTypes for frappe        : [====================] 100%
Updating country info               : [====================] 100%
Updating Dashboard for frappe
site1.local: SystemSettings.enable_scheduler is UNSET
*** Scheduler is disabled ***
frappe@erpnext14-ubuntu22041:~/frappe-bench$

It worked just like that! :slightly_smiling_face:

For those who are interested in creating an explicit user for frappe in mariadb, here is what I did.
When the command sudo mysql_secure_installation is run, terminal shows some options to configure, here is what i chose to do:

-> Configuring MariaDB
	Commands:
	
		> sudo mysql_secure_installation
	Result:
		=> Enter current password for root (enter for none): Since you have not set one up yet, press ENTER to indicate “none”. I pressed **Enter**
		=> Switch to unix_socket authentication [Y/n]: n (Since you already have a protected root account, you can skip this step. Type n and then press ENTER.)
		=> Change the root password? [Y/n]:n (Type n and then press ENTER.)
		=> Remove anonymous users? [Y/n]:y
		=> Disallow root login remotely? [Y/n]: y
		=> Remove test database and access to it? [Y/n]: y
		=> Reload privilege tables now? [Y/n]: y
	Message:
		All done!  If you've completed all of the above steps, your MariaDB installation should now be secure.
		Thanks for using MariaDB!

Then, I did as follows:

-> Creating an Administrative User that Employs Password Authentication
	Commands:
	
		> sudo mariadb
		> GRANT ALL ON *.* TO 'frappe'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
		> FLUSH PRIVILEGES;
		> exit

I am getting same error with some additional one also.

frappe@erpnext14-ubuntu22041:~/frappe-bench$ bench get-app hrms
Getting hrms
$ git clone https://github.com/frappe/hrms.git  --depth 1 --origin upstream
Cloning into 'hrms'...
remote: Enumerating objects: 1160, done.
remote: Counting objects: 100% (1160/1160), done.
remote: Compressing objects: 100% (948/948), done.
remote: Total 1160 (delta 284), reused 587 (delta 148), pack-reused 0
Receiving objects: 100% (1160/1160), 1.64 MiB | 1.65 MiB/s, done.
Resolving deltas: 100% (284/284), done.
Ignoring dependencies of hrms. To install dependencies use --resolve-deps
Installing hrms
$ /home/frappe/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /home/frappe/frappe-bench/apps/hrms 
$ bench build --app hrms
Linking /home/frappe/frappe-bench/apps/frappe/node_modules to ./assets/frappe/node_modules                                                                      Linking /home/frappe/frappe-bench/apps/erpnext/erpnext/public to ./assets/erpnext                                                                               Linking /home/frappe/frappe-bench/apps/erpnext/node_modules to ./assets/erpnext/node_modules                                                                    Linking /home/frappe/frappe-bench/apps/payments/payments/public to ./assets/payments                                                                            ✔ Application Assets Linked                                            


yarn run v1.22.19
$ node esbuild --production --apps hrms --run-build-command
clean: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
clean: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
File                                                        Size

hrms/dist/js/
└─ hrms.bundle.B55RAXO2.js                                  0.90 Kb

 DONE  Total Build Time: 1.434s

 WARN  Cannot connect to redis_cache to update assets_json
 WARN  Cannot connect to redis_cache to update assets_json
 WARN  Cannot connect to redis_cache to update assets_json
Done in 5.94s.
$ supervisorctl restart frappe:
frappe: ERROR (no such group)
frappe: ERROR (no such group)
WARN: restarting supervisor failed. Use `bench restart` to retry.

Here is my supervisord.conf file entry

[unix_http_server]
file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0700                       ; sockef file mode (default 0700)
;chmod=0700                     ;Added by LLC on 01/02/23 to solve permission problem>
chown=frappe:frappe             

Apart from that warning Cannot connect to redis_cache to update assets_json, I am also getting the permission error

> supervisorctl restart frappe
error: <class 'PermissionError'>, [Errno 13] Permission denied: file: /usr/lib/python3/dist-packages/supervisor/xmlrpc.py line: 560

This problem actually sorted as follows:
Ref URL: URL

Change the entry in supervisor.conf file to below:
file=/var/run/supervisor.sock
;chmod=0700
chmod=0770
chown=frappe:frappe

Now Run commands from frappe-bench folder:

> bench setup supervisor
> sudo ln -s `pwd`/config/supervisor.conf /etc/supervisor/conf.d/frappe-bench.conf

then restart supervisord

> sudo service supervisor restart
> sudo bench restart

Now bench will restart successfully without any issue.
Output:

$ supervisorctl restart frappe-bench-workers: frappe-bench-web:
		frappe-bench-workers:frappe-bench-frappe-schedule: stopped
		frappe-bench-workers:frappe-bench-frappe-long-worker-0: stopped
		frappe-bench-workers:frappe-bench-frappe-default-worker-0: stopped
		frappe-bench-workers:frappe-bench-frappe-short-worker-0: stopped
		frappe-bench-web:frappe-bench-node-socketio: stopped
		frappe-bench-web:frappe-bench-frappe-web: stopped
		frappe-bench-workers:frappe-bench-frappe-schedule: started
		frappe-bench-workers:frappe-bench-frappe-default-worker-0: started
		frappe-bench-workers:frappe-bench-frappe-short-worker-0: started
		frappe-bench-workers:frappe-bench-frappe-long-worker-0: started
		frappe-bench-web:frappe-bench-frappe-web: started
		frappe-bench-web:frappe-bench-node-socketio: started
		frappe@erpnext14-ubuntu22041:~/frappe-bench$

I was left to install ecommerce integrations app , so I ran command as mentioned in this guide like mentioned below and it ran successfully.

bench get-app ecommerce_integrations --branch main

Here is the output in my terminal:

frappe@erpnext14-ubuntu22041:~/frappe-bench$ bench get-app ecommerce_integrations --branch main
Getting ecommerce_integrations
$ git clone https://github.com/frappe/ecommerce_integrations.git --branch main --depth 1 --origin upstream
Cloning into 'ecommerce_integrations'...
remote: Enumerating objects: 232, done.
remote: Counting objects: 100% (232/232), done.
remote: Compressing objects: 100% (191/191), done.
remote: Total 232 (delta 40), reused 137 (delta 33), pack-reused 0
Receiving objects: 100% (232/232), 241.51 KiB | 977.00 KiB/s, done.
Resolving deltas: 100% (40/40), done.
Ignoring dependencies of ecommerce_integrations. To install dependencies use --resolve-deps
Installing ecommerce_integrations
$ /home/frappe/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /home/frappe/frappe-bench/apps/ecommerce_integrations 
$ bench build --app ecommerce_integrations
✔ Application Assets Linked                                                                                                                                         


yarn run v1.22.19
$ node esbuild --production --apps ecommerce_integrations --run-build-command
File                                                        Size

 DONE  Total Build Time: 822.729ms

clean: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
Done in 1.52s.
$ supervisorctl restart frappe-bench-workers: frappe-bench-web:
frappe-bench-workers:frappe-bench-frappe-schedule: stopped
frappe-bench-workers:frappe-bench-frappe-long-worker-0: stopped
frappe-bench-workers:frappe-bench-frappe-default-worker-0: stopped
frappe-bench-workers:frappe-bench-frappe-short-worker-0: stopped
frappe-bench-web:frappe-bench-node-socketio: stopped
frappe-bench-web:frappe-bench-frappe-web: stopped
frappe-bench-workers:frappe-bench-frappe-schedule: started
frappe-bench-workers:frappe-bench-frappe-default-worker-0: started
frappe-bench-workers:frappe-bench-frappe-short-worker-0: started
frappe-bench-workers:frappe-bench-frappe-long-worker-0: started
frappe-bench-web:frappe-bench-frappe-web: started
frappe-bench-web:frappe-bench-node-socketio: started
frappe@erpnext14-ubuntu22041:~/frappe-bench$

Surprisingly, the warning message WARN Cannot connect to redis_cache to update assets_json also did not appear

i need your help to install erpnext on my ubuntu22 desktop local server

Followed the steps, Ubuntu 22.04 LTS, but got error:

run sudo bench setup production frappeu:


TASK [supervisor : Install supervisor on debian] ******************************************************
task path: /usr/local/lib/python3.10/dist-packages/bench/playbooks/roles/supervisor/tasks/main.yml:6
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1675674568.7171948-36484-106243399285484 `" && echo ansible-tmp-1675674568.7171948-36484-106243399285484="` echo /root/.ansible/tmp/ansible-tmp-1675674568.7171948-36484-106243399285484 `" ) && sleep 0'
Using module file /usr/local/lib/python3.10/dist-packages/ansible/modules/apt.py
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-36293ngmlw3yo/tmpbv_zk_yg TO /root/.ansible/tmp/ansible-tmp-1675674568.7171948-36484-106243399285484/AnsiballZ_apt.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1675674568.7171948-36484-106243399285484/ /root/.ansible/tmp/ansible-tmp-1675674568.7171948-36484-106243399285484/AnsiballZ_apt.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1675674568.7171948-36484-106243399285484/AnsiballZ_apt.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1675674568.7171948-36484-106243399285484/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
    "cache_update_time": 1675674565,
    "cache_updated": false,
    "changed": false,
    "invocation": {
        "module_args": {
            "allow_change_held_packages": false,
            "allow_downgrade": false,
            "allow_unauthenticated": false,
            "autoclean": false,
            "autoremove": false,
            "cache_valid_time": 0,
            "clean": false,
            "deb": null,
            "default_release": null,
            "dpkg_options": "force-confdef,force-confold",
            "fail_on_autoremove": false,
            "force": true,
            "force_apt_get": false,
            "install_recommends": null,
            "lock_timeout": 60,
            "only_upgrade": false,
            "package": [
                "supervisor"
            ],
            "pkg": "supervisor",
            "policy_rc_d": null,
            "purge": false,
            "state": "present",
            "update_cache": null,
            "update_cache_retries": 5,
            "update_cache_retry_max_delay": 12,
            "upgrade": null
        }
    },
    "msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\"   --force-yes    install 'supervisor=4.2.1-1ubuntu1'' failed: W: --force-yes is deprecated, use one of the options starting with --allow instead.\nE: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 36479 (unattended-upgr)\nE: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?\n",
    "rc": 100,
    "stderr": "W: --force-yes is deprecated, use one of the options starting with --allow instead.\nE: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 36479 (unattended-upgr)\nE: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?\n",
    "stderr_lines": [
        "W: --force-yes is deprecated, use one of the options starting with --allow instead.",
        "E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 36479 (unattended-upgr)",
        "E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?"
    ],
    "stdout": "",
    "stdout_lines": []
}

PLAY RECAP ********************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=1    rescued=0    ignored=0

ERROR: Command '['ansible-playbook', '-c', 'local', 'site.yml', '-vvvv', '-e', '{"production": true, "admin_emails": "", "mysql_root_password": null, "container": false}', '-t', 'supervisor']' returned non-zero exit status 2.
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.10/dist-packages/bench/cli.py", line 127, in cli
    bench_command()
  File "/usr/lib/python3/dist-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/bench/commands/setup.py", line 368, in setup_roles
    run_playbook("site.yml", extra_vars=extra_vars, tag=role)
  File "/usr/local/lib/python3.10/dist-packages/bench/utils/__init__.py", line 325, in run_playbook
    subprocess.check_call(args, cwd=os.path.join(bench.__path__[0], "playbooks"))
  File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ansible-playbook', '-c', 'local', 'site.yml', '-vvvv', '-e', '{"production": true, "admin_emails": "", "mysql_root_password": null, "container": false}', '-t', 'supervisor']' returned non-zero exit status 2.
ERROR:
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.10/dist-packages/bench/cli.py", line 127, in cli
    bench_command()
  File "/usr/lib/python3/dist-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/bench/commands/setup.py", line 108, in setup_production
    setup_production(user=user, yes=yes)
  File "/usr/local/lib/python3.10/dist-packages/bench/config/production_setup.py", line 37, in setup_production
    setup_production_prerequisites()
  File "/usr/local/lib/python3.10/dist-packages/bench/config/production_setup.py", line 32, in setup_production_prerequisites
    exec_cmd("bench setup role supervisor")
  File "/usr/local/lib/python3.10/dist-packages/bench/utils/__init__.py", line 158, in exec_cmd
    raise CommandFailedError
bench.exceptions.CommandFailedError

maybe need to install supervisor first to overcome this problem? Site is working. But this command gives error:

bench restart:

$ supervisorctl restart frappe:
error: <class 'PermissionError'>, [Errno 13] Permission denied: file: /usr/lib/python3/dist-packages/supervisor/xmlrpc.py line: 560
ERROR:
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.10/dist-packages/bench/cli.py", line 127, in cli
    bench_command()
  File "/usr/lib/python3/dist-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/bench/commands/utils.py", line 41, in restart
    Bench(".").reload(web, supervisor, systemd)
  File "/usr/local/lib/python3.10/dist-packages/bench/utils/render.py", line 126, in wrapper_fn
    return fn(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/bench/bench.py", line 151, in reload
    restart_supervisor_processes(bench_path=self.name, web_workers=web, _raise=_raise)
  File "/usr/local/lib/python3.10/dist-packages/bench/utils/bench.py", line 315, in restart_supervisor_processes
    failure = bench.run(f"{sudo}supervisorctl restart {group}", _raise=_raise)
  File "/usr/local/lib/python3.10/dist-packages/bench/bench.py", line 48, in run
    return exec_cmd(cmd, cwd=cwd or self.cwd, _raise=_raise)
  File "/usr/local/lib/python3.10/dist-packages/bench/utils/__init__.py", line 158, in exec_cmd
    raise CommandFailedError
bench.exceptions.CommandFailedError


supervisorctl restart frappe:

error: <class 'PermissionError'>, [Errno 13] Permission denied: file: /usr/lib/python3/dist-packages/supervisor/xmlrpc.py line: 560

Site seems to running fine though.

And the line 560 in the file is self.sock.connect(self.socketfile)

class UnixStreamHTTPConnection(httplib.HTTPConnection):
    def connect(self): # pragma: no cover
        self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
        # we abuse the host parameter as the socketname
        self.sock.connect(self.socketfile)

Resolved this by changing permissions for user frappe on supervisord.

In the /etc/supervisor/supervisord.conf under add line chown… as shown below

[unix_http_server]
file=/var/tmp/supervisord.sock
chmod=0700
chown=frappe:frappe
1 Like

Really one of the best guides… thanks a lot @shashank_shirke

Hello. I am facing a similar issue to [Guide] How to install ERPNext v14 on Linux Ubuntu (step-by-step instructions) - #86 by cphoa28

I’ve installed everything up to the point at which I issue bench new-site ... command. This fails with the error:

pymysql.err.OperationalError: (1698, "Access denied for user 'root'@'localhost'")

I am trying to use an AWS RDS instance running MariaDb 10.6 as the database for my installation. I have checked I can access my RDS from the Ubuntu machine. I have set in the db_host and rds_db params in the frappe-bench/sites/common_site_config.json file as per the instructions at Using Frappe with Amazon RDS (or any other DBaaS) ¡ frappe/frappe Wiki ¡ GitHub

I also re-set the local mysql root user password.

Any suggestions for how to overcome the “Access denied …” error?

I’m trying to do this following the instructions at bench new-site but it looks like it is still trying to use a user named root at the AWS RDS side.

My bench command is:

bench new-site erp-dev2.mydomain.com --db-type mariadb --db-name erp --db-password ***** --db-host erp-dev-1.******.eu-west-2.rds.amazonaws.com

The common_site_config.json includes:

{
"db_host": "erp-dev-1.******.eu-west-2.rds.amazonaws.com",
"rds_db": 1
}

It looks like the Frappe code at frappe/db_manager.py at develop ¡ frappe/frappe ¡ GitHub is intended to manage the RDS situation by assigning only limited permissions if the rds_db flag is set:
frappe/db_manager.py at 84e20bfb177bd7d06fa5d184e3e0b7bb1bb3cb43 ¡ frappe/frappe ¡ GitHub

However, despite all this I am still getting the error:

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 109, in <module>
    main()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/home/erpnext/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/erpnext/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/erpnext/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/erpnext/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/erpnext/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/erpnext/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/commands/site.py", line 77, in new_site
    _new_site(
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/installer.py", line 80, in _new_site
    install_db(
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/installer.py", line 156, in install_db
    setup_database(force, source_sql, verbose, no_mariadb_socket)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/database/__init__.py", line 20, in setup_database
    return frappe.database.mariadb.setup_db.setup_database(
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/database/mariadb/setup_db.py", line 41, in setup_database
    if force or (db_name not in dbman.get_database_list()):
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/database/db_manager.py", line 49, in get_database_list
    return self.db.sql("SHOW DATABASES", pluck=True)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/database/database.py", line 199, in sql
    self.connect()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/database/database.py", line 113, in connect
    self._conn = self.get_connection()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 98, in get_connection
    conn = self._get_connection()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 104, in _get_connection
    return self.create_connection()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 107, in create_connection
    return pymysql.connect(**self.get_connection_settings())
  File "/home/erpnext/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 353, in __init__
    self.connect()
  File "/home/erpnext/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 633, in connect
    self._request_authentication()
  File "/home/erpnext/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 907, in _request_authentication
    auth_packet = self._read_packet()
  File "/home/erpnext/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 725, in _read_packet
    packet.raise_for_error()
  File "/home/erpnext/frappe-bench/env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "/home/erpnext/frappe-bench/env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1045, "Access denied for user 'root'@'1**.**.**.**' (using password: YES)")

Edit: I added the --db-root-username and --db-root-password flags set to values for my admin user in AWS RDS.

This time the bench new-site command seems to recognise the AWS database but there are new errors now:

Creation of your site - erp-dev2.mydomain.com failed because MariaDB is not properly 
configured.  If using version 10.2.x or earlier, make sure you use the 
the Barracuda storage engine.

The AWS RDS instance is MariaDB 10.6 and doesn’t include innodb_file_format as a parameter.

erpnext@162-241-69-63:~/frappe-bench$ bench start
15:00:28 system | redis_cache.1 started (pid=8449)
15:00:28 redis_cache.1 | 8451:C 20 Feb 2023 15:00:28.103 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
15:00:28 redis_cache.1 | 8451:C 20 Feb 2023 15:00:28.103 # Redis version=6.0.16, bits=64, commit=00000000, modified=0, pid=8451, just started
15:00:28 redis_cache.1 | 8451:C 20 Feb 2023 15:00:28.103 # Configuration loaded
15:00:28 redis_cache.1 | 8451:M 20 Feb 2023 15:00:28.104 * Increased maximum number of open files to 10032 (it was originally set to 1024).
15:00:28 redis_cache.1 | 8451:M 20 Feb 2023 15:00:28.105 # Could not create server TCP listening socket 127.0.0.1:13000: bind: Address already in use
15:00:28 system | redis_cache.1 stopped (rc=1)
15:00:28 system | redis_socketio.1 started (pid=8453)
15:00:28 redis_socketio.1 | 8454:C 20 Feb 2023 15:00:28.102 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
15:00:28 redis_socketio.1 | 8454:C 20 Feb 2023 15:00:28.102 # Redis version=6.0.16, bits=64, commit=00000000, modified=0, pid=8454, just started
15:00:28 redis_socketio.1 | 8454:C 20 Feb 2023 15:00:28.102 # Configuration loaded
15:00:28 redis_socketio.1 | 8454:M 20 Feb 2023 15:00:28.103 * Increased maximum number of open files to 10032 (it was originally set to 1024).
15:00:28 redis_socketio.1 | 8454:M 20 Feb 2023 15:00:28.103 # Could not create server TCP listening socket 127.0.0.1:12000: bind: Address already in use
15:00:28 system | redis_socketio.1 stopped (rc=1)
15:00:28 system | schedule.1 started (pid=8465)
15:00:28 system | web.1 started (pid=8459)
15:00:28 system | worker.1 started (pid=8475)
15:00:28 worker.1 | /bin/sh: 1: cannot create logs/worker.log: Permission denied
15:00:28 system | worker.1 stopped (rc=2)
15:00:28 system | redis_queue.1 started (pid=8466)
15:00:28 redis_queue.1 | 8480:C 20 Feb 2023 15:00:28.164 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
15:00:28 redis_queue.1 | 8480:C 20 Feb 2023 15:00:28.164 # Redis version=6.0.16, bits=64, commit=00000000, modified=0, pid=8480, just started
15:00:28 redis_queue.1 | 8480:C 20 Feb 2023 15:00:28.164 # Configuration loaded
15:00:28 redis_queue.1 | 8480:M 20 Feb 2023 15:00:28.165 * Increased maximum number of open files to 10032 (it was originally set to 1024).
15:00:28 redis_queue.1 | 8480:M 20 Feb 2023 15:00:28.165 # Could not create server TCP listening socket 127.0.0.1:11000: bind: Address already in use
15:00:28 system | socketio.1 started (pid=8464)
15:00:28 system | watch.1 started (pid=8462)
15:00:28 system | sending SIGTERM to redis_queue.1 (pid 8466)
15:00:28 system | sending SIGTERM to web.1 (pid 8459)
15:00:28 system | sending SIGTERM to socketio.1 (pid 8464)
15:00:28 system | sending SIGTERM to watch.1 (pid 8462)
15:00:28 system | sending SIGTERM to schedule.1 (pid 8465)
15:00:28 system | redis_queue.1 stopped (rc=1)
15:00:28 system | schedule.1 stopped (rc=-15)
15:00:28 system | socketio.1 stopped (rc=-15)
15:00:28 system | watch.1 stopped (rc=-15)
15:00:28 system | web.1 stopped (rc=-15)

You seem to have a residual process running - you need to stop that first before attempting to run a new bench start

just Perfect ! thank you very much !