Error 2003 connecting desktop app to MySQL

I just signed up for Xojo Cloud and set it up yesterday. Test web app worked well connecting to it

I want to make use of the MySQL (MariaDB) on the Xojo Cloud server for my desktop apps that have been connecting to MySQL through SiteGround. I just ran a test to connect to the new Xojo Cloud MySQL, and I am getting error number 2003 (can’t connect to MySQL server on ‘127.0.0.1’). Any btw, this same error pops up for me when I try to just run the example project Databases > MySQLDatabase, which also uses the Host as 127.0.0.1, so I don’t think it’s necessarily anything specific in my app

Yesterday when I set up the MySQL in my control panel, I also had to set up the SSH tunnel. Not sure if that has anything to do with this, but it is worth mentioning

Anyone have any ideas?

1 Like

The error (2003) Can't connect to MySQL server on 'server’ (10061) indicates that the network connection has been refused. You should check that there is a MySQL server running, that it has network connections enabled, and that the network port you specified is the one configured on the server.

Read more here:

https://dev.mysql.com/doc/refman/8.0/en/can-not-connect-to-server.html

1 Like

Hi Rick. So, I can still connect to the MySQL server through Sequel Pro (an app I use to manage the db), and the test app I built and deployed yesterday seems to still work fine (helloweb.xojocloud.net). Yesterday there was no issue with debugging in Xojo. Today there is. Even with me just opening the example project, running it, and clicking the Connect To DB button, I still get the error

Would this have anything to do with the SSH tunnel I made yesterday? Do I have to do something in Terminal to disconnect the tunnel?

I see in that link you sent to make sure the port is not blocked by a firewall. I don’t have any blocked connections in firewall

1 Like

Mimic the connection you are using for Sequel Pro, using Xojo, at the same place (network origin, IP) you can get Sequel Pro connecting, if Xojo connects too, you eliminate the “Xojo plugin does not work” and start looking at server configs, firewall, and server network protocols enabled (Xojo currently does not talk TLS1.3).

If you still can’t find a solution by yourself, try contacting the Xojo support.

1 Like

Thanks Rick. The only difference I can see between Sequel Pro is the additional fields for the SSH, but I don’t see any options to include this in the Xojo connection

I just did some investigating, though:

  • I opened another computer, opened Xojo, chose the example project Databases > MySQLDatabase, ran it, and also received the 2003 error
  • I thought maybe the problem lies in the steps I did yesterday when I set up a tunnel in Terminal per the help doc The Xojo Cloud control panel — Xojo documentation, so I did the steps in the doc in Terminal again (ssh -L 3306:localhost:3306 dbadmin@ipaddress -N [replace with your IP address of Xojo Cloud and enter the password to the tunnel]), ran my test project on the original computer, and success!
  • Again, though, trying the Xojo example project on both the original and the extra laptop still did not work after clicking the Connect to MySQL button. On my primary computer, the error is now 1045 “access denied for user ‘root’@‘localhost’ (using password: YES)”. The error on the secondary laptop still showed error 2003

This tells me the problem is that I will need to redo the tunnel connection each time I restart the computer. Is there anyway to have this information saved in Terminal where I don’t have to go through the steps every morning I want to debug?

I still do not know why the “can’t connect” message is showing on the secondary laptop when using the example project. Can someone else check theirs to make sure this is working ok?

1 Like

Adding to my investigation. I just closed the Terminal window. When prompted to “terminate running processes”, I chose Terminate. Ran my test project, and no go. Reopened Terminal and entered the credentials. Ran the test project, and it worked

Does this mean when I want to debug, I need to open Terminal, enter the creds, and keep the Terminal window open all the time? I must have missed something where this does not need to occur

Connection seems working, but login failing. Check server configs for the user and password from the origin localhost.

If you want to connect to the MySQL database on your server, you need to keep your tunnel working.

That is good to know Alberto, thank you. Follow up question to this. In my original post, I mentioned also utilizing MySQL for my desktop apps, which are distributed to users. I would like to begin moving to using the Xojo Cloud MySQL server to also house data from the desktop users in addition to my web app users. I assume if I make no change, except to change the credentials to point to the new server, then the end users would be getting these errors since they do not have an open connection. Am I correct with this assumption, or will the deployed desktop app just connect to it (in other words, do I myself only need to keep Terminal open when I am debugging?). If the end user of a deployed desktop app will need to open through the tunnel, how do I go about this to automatically have the connection available to them?

A Desktop app should never be allowed to access a web hosted database directly. You’ll need a web app that acts as an intermediary and implements a REST API.

3 Likes