kantancoding / microservices-python

256 stars 157 forks source link

MySQLdb.OperationalError: (2003, "Can't connect to MySQL server on 'host.minikube.internal:3306' (111)") #35

Closed dkaberna closed 5 months ago

dkaberna commented 5 months ago

Hello,

Many thanks for the really great video. I'm unable to authenticate via the login route. It throws an exception when calling cur = mysql.connection.cursor(). I pinged host.minikube.internal and added that IP to the hosts file. I'm not sure what else I'm supposed to do. Here's what is in my hosts file right now. Am I missing anything?

127.0.0.1 kubernetes.docker.internal # not sure if this is required 192.168.49.1 host.minikube.internal 127.0.0.1 mp3converter.com 127.0.0.1 rabbitmq-manager.com 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters

Traceback (most recent call last): File "/home/devon/system_design/python/src/auth/venv/lib/python3.10/site-packages/flask/app.py", line 1463, in wsgi_app response = self.full_dispatch_request() File "/home/devon/system_design/python/src/auth/venv/lib/python3.10/site-packages/flask/app.py", line 872, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/devon/system_design/python/src/auth/venv/lib/python3.10/site-packages/flask/app.py", line 870, in full_dispatch_request rv = self.dispatch_request() File "/home/devon/system_design/python/src/auth/venv/lib/python3.10/site-packages/flask/app.py", line 855, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(view_args) # type: ignore[no-any-return] File "/home/devon/system_design/python/src/auth/server.py", line 27, in login cur = mysql.connection.cursor() File "/home/devon/system_design/python/src/auth/venv/lib/python3.10/site-packages/flask_mysqldb/init.py", line 109, in connection ctx.mysql_db = self.connect File "/home/devon/system_design/python/src/auth/venv/lib/python3.10/site-packages/flask_mysqldb/init.py", line 97, in connect return MySQLdb.connect(kwargs) File "/home/devon/system_design/python/src/auth/venv/lib/python3.10/site-packages/MySQLdb/init.py", line 121, in Connect return Connection(*args, *kwargs) File "/home/devon/system_design/python/src/auth/venv/lib/python3.10/site-packages/MySQLdb/connections.py", line 195, in init super().init(args, **kwargs2) MySQLdb.OperationalError: (2003, "Can't connect to MySQL server on 'host.minikube.internal:3306' (111)")

dkaberna commented 5 months ago

I just saw comments from a closed issue. Apologies for not reading all of them first. I will close this.