After 2 successful years with CyberPanel, I encountered a peculiar problem few days ago. Inatalling CyberPanel with Remote SQL always leading to failures, error 1045 in CyberPanel.
django.db.utils.OperationalError: (1045, "Access denied for user 'cyberpanel'@'172.31.26.240' (using password: YES)")
Here’s are the Steps i performed and Possible Cause for this to Happen:
My Server Architecture:
- AWS EC2 as the server with c6a type instances.
- AlmaLinux 8.x / Ubuntu Minimal 20.xx as OS
- AWS RDS MariaDB with Read Replica for Database
- AWS S3 for Static Assets serving
- AWS CloudFront for CDN
Here’s the Post-Installation Result.
AWS EC2 instances have 2 type of ips, one is internal private ip, which is not accessible to the public, and another is Elastic IP, with isa Static Public IP.
Look at the Screenshot Below:
Note the Public and Private IP here.
Private IP: 172.31.26.240
Public IP: 43.204.104.194
When CyberPanel is getting installed, it Creates a USER CyberPanel, limiting the connecting host to matching the IP of Server.
Here, from the screenshot, you can see that the CYBERPANEL user is Created, limiting the host to Public IP address of the Instance : 43.204.104.194
which can be re-verified via MySQL Workbench Screenshot:
After this , as per my understanding of the Installation Logs, a local instance of Mariadb Server is created and then the details are migrated to Remote SQL via:
[07.23.2022_21-27-28] Running: /usr/local/CyberPanel/bin/python manage.py makemigrations
That’s when the Problem Occurs.
if we go through the logs we can see:
Traceback (most recent call last):
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/db/backends/base/base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 234, in get_new_connection
return Database.connect(**conn_params)
File "/usr/local/CyberPanel/lib/python3.6/site-packages/MySQLdb/__init__.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/CyberPanel/lib/python3.6/site-packages/MySQLdb/connections.py", line 185, in __init__
super().__init__(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (1045, "Access denied for user 'cyberpanel'@'172.31.26.240' (using password: YES)")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/core/management/base.py", line 371, in execute
output = self.handle(*args, **options)
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/core/management/base.py", line 85, in wrapped
res = handle_func(*args, **kwargs)
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/core/management/commands/makemigrations.py", line 101, in handle
loader.check_consistent_history(connection)
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/db/migrations/loader.py", line 290, in check_consistent_history
applied = recorder.applied_migrations()
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 77, in applied_migrations
if self.has_table():
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 55, in has_table
with self.connection.cursor() as cursor:
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/db/backends/base/base.py", line 259, in cursor
return self._cursor()
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/db/backends/base/base.py", line 235, in _cursor
self.ensure_connection()
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
self.connect()
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/db/backends/base/base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "/usr/local/CyberPanel/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 234, in get_new_connection
return Database.connect(**conn_params)
File "/usr/local/CyberPanel/lib/python3.6/site-packages/MySQLdb/__init__.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/CyberPanel/lib/python3.6/site-packages/MySQLdb/connections.py", line 185, in __init__
super().__init__(*args, **kwargs2)
django.db.utils.OperationalError: (1045, "Access denied for user 'cyberpanel'@'172.31.26.240' (using password: YES)")
The database is accessed with username cyberpanel, but the connecting IP has changed to the PRIVATE IP of the Instance i.e. 172.31.26.240.
This is when everything falls apart, and the installation fails.
I don’t think this will take to much time of you guys to resolve this, and my production server actually depends on this. So i Request you to look into it.
If there is any wrong in my installing technique, kindly let me know.
and Thanks Again for such an wonderful product that the market was void of for a very long time.
**As per my understanding, this fix will also solve majority of remote sql related problems here in the forum **