Forums

MySql Error with the new hostname

Recently I have gotten:

_mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on 'my sql.server' (111)")

on code that have worked in the past. I checked http://blog.pythonanywhere.com/128/ and I was already using the new hostname. Is there anything else I can try?

Hi there,

two things to check:

  1. did you reload your webapp after making the changes?
  2. are you sure your changed all the mysql.server to the new hostname? try doing a grep for the old hostname in your code base to double check. otherwise, try to follow the traceback to see which line of code is still using mysql.server

I was mistaken, I changed the Django hostname, but I am using the MySqlDb connector with python for this script. I am not sure how to change the hostname here. Here is the error message.

Traceback (most recent call last): File "/home/davidykan/newproject/insert/twitch.py", line 8, in <module> conn = MySQLdb.connect("mysql.server", "davidykan", "*", "", charset='utf8') File "/home/davidykan/.local/lib/python3.4/site-packages/MySQLdb/init.py", line 81, in Connect return Connection(args, kwargs) File "/home/davidykan/.local/lib/python3.4/site-packages/MySQLdb/connections.p y", line 204, in init super(Connection, self).init(*args, kwargs2) _mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on 'my sql.server' (111)")

Go to line 8 of /home/davidykan/newproject/insert/twitch.py and change the hostname accordingly.

Thanks, that fixed it.