ConnectionRefusedError: [Errno 111] Connection refused

Hi Community,
I tried creating a site with ```
bench new-site testsite

which errors out as follows:

MySQL root password: 

Installing frappe...
Updating DocTypes for frappe        : [========================================]
Traceback (most recent call last):
  File "/home/mansi/WS/sts/frappe-bench/env/lib/python3.6/site-packages/redis/connection.py", line 552, in connect
    sock = self._connect()
  File "/home/mansi/WS/sts/frappe-bench/env/lib/python3.6/site-packages/redis/connection.py", line 609, in _connect
    raise err
  File "/home/mansi/WS/sts/frappe-bench/env/lib/python3.6/site-packages/redis/connection.py", line 597, in _connect
    sock.connect(socket_address)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/mansi/WS/sts/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 97, in <module>
    main()
  File "/home/mansi/WS/sts/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/mansi/WS/sts/frappe-bench/env/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/mansi/WS/sts/frappe-bench/env/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/mansi/WS/sts/frappe-bench/env/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/mansi/WS/sts/frappe-bench/env/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/mansi/WS/sts/frappe-bench/env/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/mansi/WS/sts/frappe-bench/env/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/mansi/WS/sts/frappe-bench/apps/frappe/frappe/commands/site.py", line 36, in new_site
    no_mariadb_socket=no_mariadb_socket, db_password=db_password, db_type=db_type, db_host=db_host, db_port=db_port)
  File "/home/mansi/WS/sts/frappe-bench/apps/frappe/frappe/commands/site.py", line 81, in _new_site
    _install_app(app, verbose=verbose, set_as_patched=not source_sql)
  File "/home/mansi/WS/sts/frappe-bench/apps/frappe/frappe/installer.py", line 93, in install_app
    frappe.get_attr(after_install)()
  File "/home/mansi/WS/sts/frappe-bench/apps/frappe/frappe/utils/install.py", line 19, in after_install
    install_basic_docs()
  File "/home/mansi/WS/sts/frappe-bench/apps/frappe/frappe/utils/install.py", line 77, in install_basic_docs
    frappe.get_doc(d).insert()
  File "/home/mansi/WS/sts/frappe-bench/apps/frappe/frappe/model/document.py", line 264, in insert
    self.run_post_save_methods()
  File "/home/mansi/WS/sts/frappe-bench/apps/frappe/frappe/model/document.py", line 936, in run_post_save_methods
    self.run_method("on_update")
  File "/home/mansi/WS/sts/frappe-bench/apps/frappe/frappe/model/document.py", line 803, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/mansi/WS/sts/frappe-bench/apps/frappe/frappe/model/document.py", line 1089, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/mansi/WS/sts/frappe-bench/apps/frappe/frappe/model/document.py", line 1072, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/mansi/WS/sts/frappe-bench/apps/frappe/frappe/model/document.py", line 797, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/mansi/WS/sts/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py", line 105, in on_update
    now=frappe.flags.in_test
  File "/home/mansi/WS/sts/frappe-bench/apps/frappe/frappe/__init__.py", line 1522, in enqueue
    return frappe.utils.background_jobs.enqueue(*args, **kwargs)
  File "/home/mansi/WS/sts/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 71, in enqueue
    kwargs=queue_args)
  File "/home/mansi/WS/sts/frappe-bench/env/lib/python3.6/site-packages/rq/queue.py", line 329, in enqueue_call
    job = self.enqueue_job(job, at_front=at_front)
  File "/home/mansi/WS/sts/frappe-bench/env/lib/python3.6/site-packages/rq/queue.py", line 435, in enqueue_job
    pipe.execute()
  File "/home/mansi/WS/sts/frappe-bench/env/lib/python3.6/site-packages/redis/client.py", line 3961, in execute
    self.shard_hint)
  File "/home/mansi/WS/sts/frappe-bench/env/lib/python3.6/site-packages/redis/connection.py", line 1185, in get_connection
    connection.connect()
  File "/home/mansi/WS/sts/frappe-bench/env/lib/python3.6/site-packages/redis/connection.py", line 557, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 111 connecting to localhost:11000. Connection refused.

I tried restarting redis but didint workaround.
Please help

try to open new tab in terminal and run bench start while making new site in other terminal tab

Have a look at this

I have executed these 3 commands, i am still getting:

 pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' ([Errno 111] Connection refused)")

Last week i got same error but i resolved it

You have two step:

  1. sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

and then add in .cnf file

  1. add below top of .cnf

[mysqld]
user = mysql
pid-file = /run/mysqld/mysqld.pid
socket = /run/mysqld/mysqld.sock
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
bind-address = 127.0.0.1
query_cache_size = 16M
log_error = /var/log/mysql/error.log