Forums

(InterfaceError) 2003: Can't connect to MySQL server

I am having an error that reads InterfaceError: (InterfaceError) 2003: Can't connect to MySQL server on '<michalr.mysql.pythonanywhere-services.com>:3306' (-2 Name or service not known) None None

I am attempting to complete “A beginner’s guide to building a simple database-backed Flask website on PythonAnywhere” made by Giles. I come across this error when I am creating tables using db.create_all()

michalr.mysql.pythonanywhere-services.com is the correct database host address and I have reviewed my code, I believe it is what the tutorial asks of me.

Do you have any suggestions on where I may be going wrong?

The error is a couple hundred lines wrong almost all of it I do not understand. The interface error described above is the last line.

For my colleagues' reference, here's the results of the dig for the MySQL server you posted in a comment on the blog post:

13:53 ~/mysite (master)$ dig michalr.mysql.pythonanywhere-s...
; <<>> DiG 9.9.5-3ubuntu0.8-Ubuntu <<>> michalr.mysql.pythonanywhere-s...
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31882
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;michalr.mysql.pythonanywhere-s.... IN A
;; ANSWER SECTION:
michalr.mysql.pythonanywhere-s.... 60 IN CNAME users-mysql-1.machines.pythona....
users-mysql-1.machines.pythona.... 60 IN CNAME live-users-db-1-55.clt1czfvlzl....
live-users-db-1-55.clt1czfvlzl.... 5 IN CNAME ec2-50-17-75-142.compute-1.ama....
ec2-50-17-75-142.compute-1.ama.... 60 IN A 10.137.139.173
;; Query time: 31 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed May 18 13:53:28 UTC 2016
;; MSG SIZE rcvd: 234

Hi there,

Just realized that you said '<michalr.mysql.pythonanywhere-services.com>:3306'. You don't need the < and the >. In our instructions, we use <username>, <password>, <hostname> etc to highlight things that you need to change.

Yeppp that was the stupid kinda mistake I was expecting haha. It fixed it.

Thanks! The support you guys give is fantastic. Really appreciate it.