question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pymysql.err.OperationalError 1045, Access denied for user

See original GitHub issue

Description of the issue

When accessing localhost:8000 I got:

pymysql.err.OperationalError: (1045, u"Access denied for user ‘_69928f0f6369849a’@‘172.30.0.2’ (using password: YES)")

Context information (for bug reports)

Running the development enviroment. Using the VS code’s Remote - Containers extension

Steps to reproduce the issue

  1. Access localhost:8000 or mysite.localhost:8000 (the error shows in the console and in html format)
  2. OR Running any bench command like bench mariadb, bench console, etc (the error shows in the console)

Stacktrace / full error message if available

15:18:47 web.1            | INFO:werkzeug:172.30.0.1 - - [18/May/2020 15:18:47] "GET / HTTP/1.1" 500 -
15:18:47 web.1            | Traceback (most recent call last):
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/app.py", line 53, in application
15:18:47 web.1            |     init_request(request)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/app.py", line 120, in init_request
15:18:47 web.1            |     frappe.local.http_request = frappe.auth.HTTPRequest()
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/auth.py", line 51, in __init__
15:18:47 web.1            |     frappe.local.login_manager = LoginManager()
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/auth.py", line 113, in __init__
15:18:47 web.1            |     self.make_session(resume=True)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/auth.py", line 188, in make_session
15:18:47 web.1            |     full_name=self.full_name, user_type=self.user_type)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/sessions.py", line 194, in __init__
15:18:47 web.1            |     self.resume()
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/sessions.py", line 261, in resume
15:18:47 web.1            |     validate_ip_address(self.user)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/auth.py", line 404, in validate_ip_address
15:18:47 web.1            |     user = frappe.get_cached_doc("User", user) if not frappe.flags.in_test else frappe.get_doc("User", user)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/__init__.py", line 710, in get_cached_doc
15:18:47 web.1            |     doc = get_doc(*args, **kwargs)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/__init__.py", line 753, in get_doc
15:18:47 web.1            |     doc = frappe.model.document.get_doc(*args, **kwargs)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/model/document.py", line 69, in get_doc
15:18:47 web.1            |     controller = get_controller(doctype)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/model/base_document.py", line 37, in get_controller
15:18:47 web.1            |     module_name, custom = frappe.db.get_value("DocType", doctype, ("module", "custom"), cache=True) \
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/database/database.py", line 401, in get_value
15:18:47 web.1            |     order_by, cache=cache)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/database/database.py", line 445, in get_values
15:18:47 web.1            |     out = self._get_values_from_table(fields, filters, doctype, as_dict, debug, order_by, update)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/database/database.py", line 592, in _get_values_from_table
15:18:47 web.1            |     as_dict=as_dict, debug=debug, update=update)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/database/database.py", line 122, in sql
15:18:47 web.1            |     self.connect()
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/database/database.py", line 75, in connect
15:18:47 web.1            |     self._conn = self.get_connection()
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 96, in get_connection
15:18:47 web.1            |     conn.select_db(self.user)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py", line 446, in select_db
15:18:47 web.1            |     self._read_ok_packet()
15:18:47 web.1            |   File "/workspace/development/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py", line 394, in _read_ok_packet
15:18:47 web.1            |     pkt = self._read_packet()
15:18:47 web.1            |   File "/workspace/development/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py", line 684, in _read_packet
15:18:47 web.1            |     packet.check_error()
15:18:47 web.1            |   File "/workspace/development/frappe-bench/env/lib/python3.7/site-packages/pymysql/protocol.py", line 220, in check_error
15:18:47 web.1            |     err.raise_mysql_exception(self._data)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/env/lib/python3.7/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
15:18:47 web.1            |     raise errorclass(errno, errval)
15:18:47 web.1            | pymysql.err.OperationalError: (1044, "Access denied for user '_69928f0f6369849a'@'172.30.0.%' to database '_69928f0f6369849a'")
15:18:47 web.1            | 
15:18:47 web.1            | During handling of the above exception, another exception occurred:
15:18:47 web.1            | 
15:18:47 web.1            | Traceback (most recent call last):
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/middlewares.py", line 16, in __call__
15:18:47 web.1            |     return super(StaticDataMiddleware, self).__call__(environ, start_response)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/env/lib/python3.7/site-packages/werkzeug/middleware/shared_data.py", line 220, in __call__
15:18:47 web.1            |     return self.app(environ, start_response)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/env/lib/python3.7/site-packages/werkzeug/middleware/shared_data.py", line 220, in __call__
15:18:47 web.1            |     return self.app(environ, start_response)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/env/lib/python3.7/site-packages/werkzeug/local.py", line 231, in application
15:18:47 web.1            |     return ClosingIterator(app(environ, start_response), self.cleanup)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/env/lib/python3.7/site-packages/werkzeug/wrappers/base_request.py", line 237, in application
15:18:47 web.1            |     resp = f(*args[:-2] + (request,))
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/app.py", line 83, in application
15:18:47 web.1            |     response = handle_exception(e)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/app.py", line 194, in handle_exception
15:18:47 web.1            |     http_status_code=http_status_code)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/website/render.py", line 33, in render
15:18:47 web.1            |     raise_if_disabled(path)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/website/render.py", line 345, in raise_if_disabled
15:18:47 web.1            |     'route': ['like', '%{0}'.format(path)]
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/database/database.py", line 528, in get_all
15:18:47 web.1            |     return frappe.get_all(*args, **kwargs)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/__init__.py", line 1318, in get_all
15:18:47 web.1            |     return get_list(doctype, *args, **kwargs)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/__init__.py", line 1291, in get_list
15:18:47 web.1            |     return frappe.model.db_query.DatabaseQuery(doctype).execute(None, *args, **kwargs)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/model/db_query.py", line 96, in execute
15:18:47 web.1            |     result = self.build_and_run()
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/model/db_query.py", line 110, in build_and_run
15:18:47 web.1            |     args = self.prepare_args()
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/model/db_query.py", line 136, in prepare_args
15:18:47 web.1            |     self.set_optional_columns()
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/model/db_query.py", line 298, in set_optional_columns
15:18:47 web.1            |     columns = get_table_columns(self.doctype)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/model/meta.py", line 49, in get_table_columns
15:18:47 web.1            |     return frappe.db.get_table_columns(doctype)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/database/database.py", line 863, in get_table_columns
15:18:47 web.1            |     columns = self.get_db_table_columns('tab' + doctype)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/database/database.py", line 854, in get_db_table_columns
15:18:47 web.1            |     where table_name = %s ''', table)]
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/database/database.py", line 122, in sql
15:18:47 web.1            |     self.connect()
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/database/database.py", line 75, in connect
15:18:47 web.1            |     self._conn = self.get_connection()
15:18:47 web.1            |   File "/workspace/development/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 96, in get_connection
15:18:47 web.1            |     conn.select_db(self.user)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py", line 446, in select_db
15:18:47 web.1            |     self._read_ok_packet()
15:18:47 web.1            |   File "/workspace/development/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py", line 394, in _read_ok_packet
15:18:47 web.1            |     pkt = self._read_packet()
15:18:47 web.1            |   File "/workspace/development/frappe-bench/env/lib/python3.7/site-packages/pymysql/connections.py", line 684, in _read_packet
15:18:47 web.1            |     packet.check_error()
15:18:47 web.1            |   File "/workspace/development/frappe-bench/env/lib/python3.7/site-packages/pymysql/protocol.py", line 220, in check_error
15:18:47 web.1            |     err.raise_mysql_exception(self._data)
15:18:47 web.1            |   File "/workspace/development/frappe-bench/env/lib/python3.7/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
15:18:47 web.1            |     raise errorclass(errno, errval)
15:18:47 web.1            | pymysql.err.OperationalError: (1044, "Access denied for user '_69928f0f6369849a'@'172.30.0.%' to database '_69928f0f6369849a'")

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
roquegvcommented, May 18, 2020

The problem seems to be with the IP address, which is constanly changing.

The way I manage to workaroud this problem is by:

  1. Enter the mariadb docker container: docker exec -ti <CONTAINER_ID> bash
  2. Enter mysql: mysql -u root -p (default pass is 123)
  3. Using wildcards for mysql.user’s and mysql.db’s Hosts: 3.1. UPDATE mysql.user SET host = '172.30.0.%' WHERE host = '172.30.0.2'; 3.2. UPDATE mysql.db SET host = '172.30.0.%' WHERE host = '172.30.0.2'; 3.3. FLUSH PRIVILEGES;

Then it works.

This is just a workaround. There should be a better solution. Thanks

1reaction
revantcommented, May 18, 2020

Now there is --no-mariadb-socket option available in bench new-site command. It sets the credential suitable for docker at the time of site creation.

pull the latest bench image

docker pull frappe/bench:latest
Read more comments on GitHub >

github_iconTop Results From Across the Web

pymysql.err.OperationalError: (1045, "Access denied for user ...
I am getting this error. pymysql.err.OperationalError: (1045, "Access denied for user 'MYID'@'localhost' (using password: NO)").
Read more >
pymysql.err.OperationalError - (1045, "Access denied for user ...
I install ERPNext in Vultr(Ubuntu). i face the belo error msg. ... GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY 'your_password' WITH ......
Read more >
Access denied for user (using password: YES)" - DevAnswers.co
Your certain your MySQL password is correct but you are getting "Error 1045: Access denied for user (using password: YES)".
Read more >
(1045, 'Access denied for user 'root'@'localhost' (using ... - Quora
First, connect directly to MySQL with the root user. If you cannot, then you need to figure out the password, or reset the...
Read more >
(OperationalError) (1045, "Access denied for user 'heat ... - IBM
"ERROR: (OperationalError) (1045, "Access denied for user 'heat'@'localhost' (using password: YES)")" while installing IBM UrbanCode Heat orchestration ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found