Hello...
When trying to start my django site, I can't seem to make a connection remotely (using Windows). I used this article: https://help.pythonanywhere.com/pages/AccessingMySQLFromOutsidePythonAnywhere/
What I did/know:
- I can connect to SQL Workbench remotely through the tunnel.
- I can connect from my 2 sites hosted on pythonanywhere without the tunnel just fine.
- The dev system is set to use the database at 127.0.0.1 per the docs.
- The issue is only in my dev environment remotely, and I am connected to the tunnel over SSH when the error occurs.
I keep getting this traceback, anyone have any ideas?
System check identified no issues (0 silenced).
Exception in thread django-main-thread:
Traceback (most recent call last):
File "(path removed)\lib\site-packages\django\db\backends\base\base.py", line 289, in ensure_connection
self.connect()
File "(path removed)\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "(path removed)\lib\site-packages\django\db\backends\base\base.py", line 270, in connect
self.connection = self.get_new_connection(conn_params)
File "(path removed)\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "(path removed)\lib\site-packages\django\db\backends\mysql\base.py", line 247, in get_new_connection
connection = Database.connect(**conn_params)
File "(path removed)\lib\site-packages\MySQLdb\__init__.py", line 123, in Connect
return Connection(*args, **kwargs)
File "(path removed)\lib\site-packages\MySQLdb\connections.py", line 185, in __init__
super().__init__(*args, **kwargs2)
MySQLdb.OperationalError: (2013, "Lost connection to server at 'handshake: reading initial communication packet', system error: 0")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Python\Python310\lib\threading.py", line 1016, in _bootstrap_inner
self.run()
File "C:\Python\Python310\lib\threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "(path removed)\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "(path removed)\lib\site-packages\django\core\management\commands\runserver.py", line 136, in inner_run
self.check_migrations()
File "(path removed)\lib\site-packages\django\core\management\base.py", line 574, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "(path removed)\lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "(path removed)\lib\site-packages\django\db\migrations\loader.py", line 58, in __init__
self.build_graph()
File "(path removed)\lib\site-packages\django\db\migrations\loader.py", line 235, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "(path removed)\lib\site-packages\django\db\migrations\recorder.py", line 81, in applied_migrations
if self.has_table():
File "(path removed)\lib\site-packages\django\db\migrations\recorder.py", line 57, in has_table
with self.connection.cursor() as cursor:
File "(path removed)\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "(path removed)\lib\site-packages\django\db\backends\base\base.py", line 330, in cursor
return self._cursor()
File "(path removed)\lib\site-packages\django\db\backends\base\base.py", line 306, in _cursor
self.ensure_connection()
File "(path removed)\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "(path removed)\lib\site-packages\django\db\backends\base\base.py", line 288, in ensure_connection
with self.wrap_database_errors:
File "(path removed)\lib\site-packages\django\db\utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "(path removed)\lib\site-packages\django\db\backends\base\base.py", line 289, in ensure_connection
self.connect()
File "(path removed)\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "(path removed)\lib\site-packages\django\db\backends\base\base.py", line 270, in connect
self.connection = self.get_new_connection(conn_params)
File "(path removed)\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "(path removed)\lib\site-packages\django\db\backends\mysql\base.py", line 247, in get_new_connection
connection = Database.connect(**conn_params)
File "(path removed)\lib\site-packages\MySQLdb\__init__.py", line 123, in Connect
return Connection(*args, **kwargs)
File "(path removed)\lib\site-packages\MySQLdb\connections.py", line 185, in __init__
super().__init__(*args, **kwargs2)
django.db.utils.OperationalError: (2013, "Lost connection to server at 'handshake: reading initial communication packet', system error: 0")