I encounter this error: OperationalError: (2003, "Can't connect to MySQL server on u'localhost' ([Errno 111] Connection refused)")

Traceback (most recent call last):
File “/home/wencel/Desktop/sample/frappe-bench/apps/frappe/frappe/middlewares.py”, line 15, in call
return super(StaticDataMiddleware, self).call(environ, start_response)
File “/home/wencel/Desktop/sample/frappe-bench/env/lib/python2.7/site-packages/werkzeug/middleware/shared_data.py”, line 227, in call
return self.app(environ, start_response)
File “/home/wencel/Desktop/sample/frappe-bench/env/lib/python2.7/site-packages/werkzeug/middleware/shared_data.py”, line 227, in call
return self.app(environ, start_response)
File “/home/wencel/Desktop/sample/frappe-bench/env/lib/python2.7/site-packages/werkzeug/local.py”, line 231, in application
return ClosingIterator(app(environ, start_response), self.cleanup)
File “/home/wencel/Desktop/sample/frappe-bench/env/lib/python2.7/site-packages/werkzeug/wrappers/base_request.py”, line 235, in application
resp = f(*args[:-2] + (request,))
File “/home/wencel/Desktop/sample/frappe-bench/apps/frappe/frappe/app.py”, line 81, in application
response = handle_exception(e)
File “/home/wencel/Desktop/sample/frappe-bench/apps/frappe/frappe/app.py”, line 191, in handle_exception
http_status_code=http_status_code)
File “/home/wencel/Desktop/sample/frappe-bench/apps/frappe/frappe/website/render.py”, line 33, in render
raise_if_disabled(path)
File “/home/wencel/Desktop/sample/frappe-bench/apps/frappe/frappe/website/render.py”, line 345, in raise_if_disabled
‘route’: [‘like’, ‘%{0}’.format(path)]
File “/home/wencel/Desktop/sample/frappe-bench/apps/frappe/frappe/database/database.py”, line 527, in get_all
return frappe.get_all(*args, **kwargs)
File “/home/wencel/Desktop/sample/frappe-bench/apps/frappe/frappe/init.py”, line 1291, in get_all
return get_list(doctype, *args, **kwargs)
File “/home/wencel/Desktop/sample/frappe-bench/apps/frappe/frappe/init.py”, line 1264, in get_list
return frappe.model.db_query.DatabaseQuery(doctype).execute(None, *args, **kwargs)
File “/home/wencel/Desktop/sample/frappe-bench/apps/frappe/frappe/model/db_query.py”, line 94, in execute
result = self.build_and_run()
File “/home/wencel/Desktop/sample/frappe-bench/apps/frappe/frappe/model/db_query.py”, line 108, in build_and_run
args = self.prepare_args()
File “/home/wencel/Desktop/sample/frappe-bench/apps/frappe/frappe/model/db_query.py”, line 130, in prepare_args
self.set_optional_columns()
File “/home/wencel/Desktop/sample/frappe-bench/apps/frappe/frappe/model/db_query.py”, line 281, in set_optional_columns
columns = frappe.db.get_table_columns(self.doctype)
File “/home/wencel/Desktop/sample/frappe-bench/apps/frappe/frappe/database/database.py”, line 848, in get_table_columns
columns = self.get_db_table_columns(‘tab’ + doctype)
File “/home/wencel/Desktop/sample/frappe-bench/apps/frappe/frappe/database/database.py”, line 844, in get_db_table_columns
where table_name = %s ‘’’, table)]
File “/home/wencel/Desktop/sample/frappe-bench/apps/frappe/frappe/database/database.py”, line 122, in sql
self.connect()
File “/home/wencel/Desktop/sample/frappe-bench/apps/frappe/frappe/database/database.py”, line 75, in connect
self._conn = self.get_connection()
File “/home/wencel/Desktop/sample/frappe-bench/apps/frappe/frappe/database/mariadb/database.py”, line 90, in get_connection
local_infile = frappe.conf.local_infile)
File “/home/wencel/Desktop/sample/frappe-bench/env/lib/python2.7/site-packages/pymysql/init.py”, line 94, in Connect
return Connection(*args, **kwargs)
File “/home/wencel/Desktop/sample/frappe-bench/env/lib/python2.7/site-packages/pymysql/connections.py”, line 325, in init
self.connect()
File “/home/wencel/Desktop/sample/frappe-bench/env/lib/python2.7/site-packages/pymysql/connections.py”, line 630, in connect
raise exc
OperationalError: (2003, “Can’t connect to MySQL server on u’localhost’ ([Errno 111] Connection refused)”)

Hi, please see this thread OperationalError: (2003, "Can't connect to MySQL server on u'localhost' ([Errno 111] Connection refused)")

Good day Mam,

I already tried these commands:

sudo service mysql stop
sudo service mysql start

After issuing the command, here’s what happened

Failed to add /run/systemd/ask-password to directory watch: No space left on device
Job for mariadb.service failed because the control process exited with error code.
See “systemctl status mariadb.service” and “journalctl -xe” for details.

I also tried to reinstall mariadb, but same error pops

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

This topic was recently covered here

The Above issue can be fixed by following the steps mentioned below:

sudo mysqld --tc-heuristic-recover=ROLLBACK
sudo service mysqld restart

hi graspcipher,

try this
sudo service mysql stop
sudo service mysql start