OperationalError: (2003, "Can't connect to MySQL server on u'localhost' ([Errno 61] Connection refused)")

Hi, I am trying to install erp next on macos high sierra as instructed on website and I am stuck at this error OperationalError: (2003, “Can’t connect to MySQL server on u’localhost’ ([Errno 61] Connection refused)”)
on creation of new-site. can some please guide what am I doing wrong?

Seems mysql service is down

Do server.mysql restart.

1 Like

i have same error, but in my issue mysql server is running… i let here all error:

$ bench init frappe-bench && cd frappe-bench
<—
all the good stuff
---->

$ bench new-site erp.local
MySQL root password:
Traceback (most recent call last):
File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py”, line 174, in _run_module_as_main
main”, fname, loader, pkg_name)
File “/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/Developers/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 97, in
main()
File “/Developers/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/Developers/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/Developers/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/Developers/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/Developers/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/Developers/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/Developers/frappe-bench/env/lib/python2.7/site-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/Developers/frappe-bench/apps/frappe/frappe/commands/site.py”, line 33, in new_site
db_type = db_type)
File “/Developers/frappe-bench/apps/frappe/frappe/commands/site.py”, line 66, in _new_site
source_sql=source_sql,force=force, reinstall=reinstall, db_type=db_type)
File “/Developers/frappe-bench/apps/frappe/frappe/installer.py”, line 36, in install_db
setup_database(force, source_sql, verbose)
File “/Developers/frappe-bench/apps/frappe/frappe/database/init.py”, line 16, in setup_database
return frappe.database.mariadb.setup_db.setup_database(force, source_sql, verbose)
File “/Developers/frappe-bench/apps/frappe/frappe/database/mariadb/setup_db.py”, line 13, in setup_database
if force or (db_name not in dbman.get_database_list()):
File “/Developers/frappe-bench/apps/frappe/frappe/database/db_manager.py”, line 58, in get_database_list
return [d[0] for d in self.db.sql(“SHOW DATABASES”)]
File “/Developers/frappe-bench/apps/frappe/frappe/database/database.py”, line 120, in sql
self.connect()
File “/Developers/frappe-bench/apps/frappe/frappe/database/database.py”, line 73, in connect
self._conn = self.get_connection()
File “/Developers/frappe-bench/apps/frappe/frappe/database/mariadb/database.py”, line 85, in get_connection
local_infile = frappe.conf.local_infile)
File “/Developers/frappe-bench/env/lib/python2.7/site-packages/pymysql/init.py”, line 94, in Connect
return Connection(*args, **kwargs)
File “/Developers/frappe-bench/env/lib/python2.7/site-packages/pymysql/connections.py”, line 327, in init
self.connect()
File “/Developers/frappe-bench/env/lib/python2.7/site-packages/pymysql/connections.py”, line 629, in connect
raise exc
pymysql.err.OperationalError: (2003, “Can’t connect to MySQL server on u’localhost’ ([Errno 61] Connection refused)”)

$ ps aux | grep mysql
_mysql 41665 0.0 0.7 4686028 176692 ?? Ss 9:38PM 0:02.09 /opt/local/lib/mysql57/bin/mysqld
gvargas 49448 0.0 0.0 4267768 732 s004 S+ 12:23AM 0:00.00 grep mysql

$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.7.17 Source distribution

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql>

can please any one help me ??

by the way… it still working until i upgrade to macOS High Sierra…

  • Have you checked that the port is not blocked by a firewall update?
  • You may need to set permissions
    eg.

mysql -uroot -pYOURmysqlPASSWORD -Bse “GRANT ALL PRIVILEGES ON . TO ‘root’@‘localhost’ IDENTIFIED BY ‘YOURmysqlPASSWORD’ WITH GRANT OPTION;”

It’s not a Frappe/ERPNext.

Error Explanation:

Connection Confused error occurs when user try to access remote resources on wrongs remote address or your network connection is breaking sometime.
Another reasons can be you have entered incorrect password or tried to cross the limit of incorrect password to login into the remote server.
To resolve this, please verify the remote address IP( for eg. 199.22.110.11) whether is correct or not.
Use ping utility to verify the address

If you’re facing this issue on localhost then It can be related to user creation and role & permissions.

Firewall deactivated.
and i do that u recommend me about permissions and it doesn’t work.

i think is something about “localhost”

Thank u, but this is not a remote connection all is local

pymysql.err.OperationalError: (2003, “Can’t connect to MySQL server on u’localhost’ ([Errno 61] Connection refused)”)

$ mysql -u root -p -h localhost

Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.7.17 Source distribution

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> exit
Bye

$ mysql -u root -p -h 127.0.0.1

Enter password:
ERROR 2003 (HY000): Can’t connect to MySQL server on ‘127.0.0.1’ (61)

$ cat /etc/hosts

Host Database

localhost is used to configure the loopback interface
when the system is booting. Do not change this entry.

127.0.0.1 localhost
255.255.255.255 broadcasthost

so, no idea where is the problem

ok… i solved my problem with mysql 8… now had this one:

2018-09-28T18:12:54.283323Z 0 [System] [MY-010116] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.12) starting as process 47302
2018-09-28T18:12:54.288561Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
2018-09-28T18:12:54.325423Z 1 [ERROR] [MY-012574] [InnoDB] InnoDB: Unable to lock ./ibdata1 error: 35
2018-09-28T18:12:55.328348Z 1 [ERROR] [MY-012574] [InnoDB] InnoDB: Unable to lock ./ibdata1 error: 35
[warn] kq_init: detected broken kqueue; not using.: Invalid argument
2018-09-28T18:12:56.638428Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2018-09-28T18:12:56.641750Z 0 [ERROR] [MY-011071] [Server] unknown variable ‘innodb-file-format=barracuda’
2018-09-28T18:12:56.641778Z 0 [Warning] [MY-010952] [Server] The privilege system failed to initialize correctly. If you have upgraded your server, make sure you’re executing mysql_upgrade to correct the issue.
2018-09-28T18:12:56.642060Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-09-28T18:12:58.211996Z 0 [System] [MY-010910] [Server] /usr/local/mysql/bin/mysqld: Shutdown complete (mysqld 8.0.12) MySQL Community Server - GPL.

so… this mean mysql 8 isn’t compatible ??

ahhh by the way… it appears because this:

$ bench new-site erp.local
MySQL root password:

Creation of your site - erp.local failed because MariaDB is not properly
configured to use the Barracuda storage engine.
Please add the settings below to MariaDB’s my.cnf, restart MariaDB then
run bench new-site erp.local again.

[mysqld]
innodb-file-format=barracuda
innodb-file-per-table=1
innodb-large-prefix=1
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

[mysql]
default-character-set = utf8mb4

================================================================================

This topic was automatically closed after 5 days. New replies are no longer allowed.