[SOLVED] Error when update - mysql connection refused

I am doing update and got an error.

Backing up sites…
Traceback (most recent call last):
File “/usr/lib64/python2.7/runpy.py”, line 162, in _run_module_as_main
main”, fname, loader, pkg_name)
File “/usr/lib64/python2.7/runpy.py”, line 72, in _run_code
exec code in run_globals
File “/home/userbench/erp-zip/apps/frappe/frappe/utils/bench_helper.py”, line 94, in
File “/home/userbench/erp-zip/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
File “/home/userbench/erp-zip/env/lib/python2.7/site-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/home/userbench/erp-zip/env/lib/python2.7/site-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/home/userbench/erp-zip/env/lib/python2.7/site-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/userbench/erp-zip/env/lib/python2.7/site-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/userbench/erp-zip/env/lib/python2.7/site-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/userbench/erp-zip/env/lib/python2.7/site-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/userbench/erp-zip/env/lib/python2.7/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/userbench/erp-zip/apps/frappe/frappe/commands/init.py”, line 24, in _func
ret = f(frappe.dict(ctx.obj), *args, **kwargs)
File “/home/userbench/erp-zip/apps/frappe/frappe/commands/site.py”, line 294, in backup
odb = scheduled_backup(ignore_files=not with_files, backup_path_db=backup_path_db, backup_path_files=backup_path_files, backup_path_private_files=backup_path_private_files, force=True)
File “/home/userbench/erp-zip/apps/frappe/frappe/utils/backups.py”, line 166, in scheduled_backup
odb = new_backup(older_than, ignore_files, backup_path_db=backup_path_db, backup_path_files=backup_path_files, force=force)
File “/home/userbench/erp-zip/apps/frappe/frappe/utils/backups.py”, line 176, in new_backup
odb.get_backup(older_than, ignore_files, force=force)
File “/home/userbench/erp-zip/apps/frappe/frappe/utils/backups.py”, line 48, in get_backup
File “/home/userbench/erp-zip/apps/frappe/frappe/utils/backups.py”, line 63, in set_backup_file_name
todays_date = now_datetime().strftime('%Y%m%d
File “/home/userbench/erp-zip/apps/frappe/frappe/utils/data.py”, line 122, in now_datetime
dt = convert_utc_to_user_timezone(datetime.datetime.utcnow())
File “/home/userbench/erp-zip/apps/frappe/frappe/utils/data.py”, line 145, in convert_utc_to_user_timezone
return utcnow.astimezone(timezone(get_time_zone()))
File “/home/userbench/erp-zip/apps/frappe/frappe/utils/data.py”, line 139, in get_time_zone
return frappe.cache().get_value(“time_zone”, _get_time_zone)
File “/home/userbench/erp-zip/apps/frappe/frappe/utils/redis_wrapper.py”, line 72, in get_value
val = generator()
File “/home/userbench/erp-zip/apps/frappe/frappe/utils/data.py”, line 133, in _get_time_zone
return frappe.db.get_system_setting(‘time_zone’) or ‘Asia/Kolkata’
File “/home/userbench/erp-zip/apps/frappe/frappe/database.py”, line 871, in get_system_setting
return frappe.cache().get_value(“system_settings”, _load_system_settings).get(key)
File “/home/userbench/erp-zip/apps/frappe/frappe/utils/redis_wrapper.py”, line 72, in get_value
val = generator()
File “/home/userbench/erp-zip/apps/frappe/frappe/database.py”, line 870, in _load_system_settings
return self.get_singles_dict(“System Settings”)
File “/home/userbench/erp-zip/apps/frappe/frappe/database.py”, line 555, in get_singles_dict
tabSingles where doctype=%s"“”, doctype))
File “/home/userbench/erp-zip/apps/frappe/frappe/database.py”, line 136, in sql
File “/home/userbench/erp-zip/apps/frappe/frappe/database.py”, line 86, in connect
charset=‘utf8mb4’, use_unicode = True, conv = conversions)
File “/home/userbench/erp-zip/env/lib/python2.7/site-packages/pymysql/init.py”, line 90, in Connect
return Connection(*args, **kwargs)
File “/home/userbench/erp-zip/env/lib/python2.7/site-packages/pymysql/connections.py”, line 699, in init
File “/home/userbench/erp-zip/env/lib/python2.7/site-packages/pymysql/connections.py”, line 967, in connect
raise exc
pymysql.err.OperationalError: (2003, “Can’t connect to MySQL server on u’localhost’ ([Errno 111] Connection refused)”)

as you can see, error happened when doing backup for database.
I tried to test the connection to all of my database with the same config on site_config.json, I don’t get any problem.
at the last line it says

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

why u’localhost’ ? not the u’mysql_user’

need help here,
Thank you guys.

Can you do a bench mysql and get in to a command prompt with no other typing?

No problem with bench mysql

user@host erp-zip]$ bench mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2100
Server version: 10.0.33-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab an

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

MariaDB [40634a08c8cdd]

Anyone can help?

Hi @ical ,
Try to restart it.
sudo service mysql restart


thank you for your reply, but sorry it doesn’t work. I try to rebuild mariadb configuration at server.cnf and it solve the mysql problem, maybe newer version mariadb disable some configs value related to innodb setting, and i success to execute bench update command.
After updating I got another problem, redis_server can not running.
I solved by

  • create new bench folder, ‘bench init new-bench-folder’
  • create newsite.local, ‘bench new-site newsite.local’
  • move oldsite.local content (from old bench folder) to newsite.local folder.
  • bench update --reset
  • bench --site newsite.local migrate
  • bench clear-cache
  • bench start
  • done

Thank you