Hi I have a MySQL server that I need access through a VPN.

I use MySQLdb package to access MySQL server in Python.

When I can access the server without VPN, it works fine, but when I'm at certain locations, I need to connect through VPN.

My computer is connected to the VPN and I can access the database through PHPMyAdmin, but MySQLdb gives me an error message: OperationalError: (2003, "Can't connect to MySQL server on 'MY_IP' (10061)")

Any ideas on why it's not working? Thanks

migrated from stackoverflow.com Apr 9 '10 at 4:23

This question came from our site for professional and enthusiast programmers.

  • Sounds like more of a Server Fault issue. Your problem is not with Python. – jemfinch Apr 8 '10 at 23:19

PHPMyAdmin is a web application, which your VPN probably lets by with ease (TCP port 80 or https on 443). Your VPN probably isn't letting the MySQL port though (TCP 3306, if it is the default).

Good luck,



To check Jed's suggestion above (open a cmd window if you are on Windows) replace with the IP or hostname of your mysql server. If it's blocked you will see something like :

$ telnet 3306

and eventually a timeout.

If you can reach the port then you should see something similar to:

$ telnet 3306
Connected to
Escape character is '^]'.
5.1.37-1ubuntu5.1C[&Elne0d])O5ZG4mKmdConnection closed by foreign host.

If it's the former, then show that to the VPN/Firewall admin person and they should be able to help.

Hope this helps.


By default, MySQL only allows TCP connections from localhost - assuming your python application is running on the same machine as MySQL, ensure that your MySQL bindings are to the local IP address, not just and that there is no firewall on the machine preventing connections on port 3306.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy