Unable to to perform final installation steps of ERPNext - New Installation Stuck at "bench new-site [sitename]' Command

Dear All, this is not exactly a new issue. I have encountered it before, and as I did not get any reply, I have been forced to dump ERPNext for a good while.
After an uneventful installation up to tihs point,

bench new-site --db-name frappe_my.site my.site

just hangs. Forever. No log entry, no stdout. Nada. Subdirectories are created. That’s it. Doing

mysql -u root -p -h [remote mysql server] frappe_my.site

works, of course.

Although bench can be taught to accept a non-local MariaDB server, could it be that this feature does not actually work, and MySQL/MariaDB has to be local?

Hi @chlarsen,
Please check bench --help in frappe-bench folder & check mysql is install or not correctly.
what it shows ?if nothing try bench update.


Thanks a lot for your quick reply. I can use call the mysql client from the same FreeBSD jail ERPNext is supposed to be installed in, and can connect ot the server with exactly the same credentials without any problems.
I have also just managed to redirect MySQL requests to via firewall - so bench should think that MySQL/MariaDB are installed locally. Alas, the problem persists.

Dear All,

After trying

bench set-mariadb-host [remote MariaDB server]

and getting nothing but endless, silent hangs, I am getting somewhere. Could it be that bench insists on a MySQL socket? After redirecting MySQL requests via pf from the database server to the server, where ERPNext is to be installed, and running:

bench new-site --db-name frappe_my.site my.site

I get:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/local/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 79, in <module>
  File "/usr/local/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 16, in main
  File "/usr/local/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 26, in new_site
    verbose=verbose, install_apps=install_app, source_sql=source_sql, force=force)
  File "/usr/local/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 56, in _new_site
    admin_password=admin_password, verbose=verbose, source_sql=source_sql,force=force, reinstall=reinstall)
  File "/usr/local/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 34, in install_db
    create_database_and_user(force, verbose)
  File "/usr/local/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 52, in create_database_and_user
    if force or (db_name not in dbman.get_database_list()):
  File "/usr/local/frappe/frappe-bench/apps/frappe/frappe/model/db_schema.py", line 542, in get_database_list
    return [d[0] for d in self.db.sql("SHOW DATABASES")]
  File "/usr/local/frappe/frappe-bench/apps/frappe/frappe/database.py", line 106, in sql
  File "/usr/local/frappe/frappe-bench/apps/frappe/frappe/database.py", line 52, in connect
    use_unicode=True, charset='utf8')
  File "/usr/local/frappe/frappe-bench/env/lib/python2.7/site-packages/MySQLdb/__init__.py", line 81, in Connect
    return Connection(*args, **kwargs)
  File "/usr/local/frappe/frappe-bench/env/lib/python2.7/site-packages/MySQLdb/connections.py", line 193, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)")

This clearly indicates a case of cold turkey for sockets… Despite the MariaDB port being forwarded to, not localhost!
Any thoughts?

Hey @chlarsen , I believe you are using bench flags --db-name incorrectly.

Please try something like: bench new-site my.site --db-name frappe_my_site

Just tried several times - re-ordering options vs parameters does not seem to make any difference. Or am I missing something really gross and stupid?

@chlarsen You are using ERPnext, you are not stupid :slight_smile: , you are most clever than ever.

Based on this “Can’t connect to local MySQL server” , is mysql running ?

Hahaha - thanks! Mysql is running. Here is my architecture:

FreeBSD server, with several jails. One jail for the MariaDB server, another for the Nginx reverse proxy, another for djbDNS, another for mail, another ERPNext, etc. etc.
I have installed the MariaDB client inside the jail, where ERPNext is to be installed, and can access the MariaDB server jail without problems.
Could it be the Pyton-MySQL glue? Which one should I use? There a three options:

py-MySQLdb (GitHub - farcepest/MySQLdb1: MySQL database connector for Python (legacy version)),
py-mysql-connector-python (http://dev.mysql.com/doc/connector-python/en), or
py-mysqlclient (GitHub - PyMySQL/mysqlclient: MySQL database connector for Python (with Python 3 support)).


I am not an expert in server management etc but I get the idea

2 suggestions / questions

  1. Dummy one: MariaDB jail (as you say) has an internet that you have to open? I thinking that in my home server to export the database to my local I have reconfig to accept connection from specific host and ports so maybe you need to conf MariaDB like that.
  2. Python wrapper to my local system: MySQL-python==1.2.5

Thanks for your reply, as always. MySQL (oops: MariaDB) is properly configured, because I can actually use the mysql client programme to connect as root to the remote server from the ERPNext box.
Out of sheer despair (and for radical debugging) I am now installing a local instance of MariaDB on the ERPNext box. Will keep you informed.
Yep, python-mysql lgue noted, and I have the same, courtesy of pip. Thanks!

Even with a local Mysql/MariaDB server instance, bench new-site [new site name] hangs forever.
There is some issue with the mysql/mariadb to python glue, I guess.
Any help, suggestions?

Further updates: I got this far, and the MariaDB user and database are actually created. However, the script seems to get stuck, when it comes to creating the ERPNext admin user. Also, the MySQL user and database creations are incredibly slow.

bench new-site --db-name new.site.db --mariadb-root-username root --mariadb-root-password root.password --admin-password erpnext.admin.password --verbose new.site
Created user new.site.db
Created database new.site.db
Granted privileges to user new.site.db and database new.site.db
Starting database import...
Imported from database /usr/local/frappe/frappe-bench/apps/frappe/frappe/data/Framework.sql

This remains to be strange. No log entries, nothing. Any thoughts?
Thanks a million,


I got stuck at mySQL step too with this error
fatal: [localhost]: FAILED! => {“changed”: false, “failed”: true, “msg”: "systemd could not find the requested service "‘mysql’": "}

Checked the server mysql service is running.
Any ideas?

Hi Princess, try to access your MySQL (or MariaDB) server via:
mysql -u root -p localhost
I presume that you have installed the server locally? If you can access your MySQL/MariaDB server by means of the mysql client programme, you just have to make sure that bench knows about the server. Do:
bench set-mariadb-host mysql.jail.vlan
as frappe/erpnext user from within the frappe-bench folder before installing the site.

I’ve been there, done this: [Fixed] Can't connect to local MySQL server through socket '/tmp/mysql.sock'