I have a local setup using PHP for the backend, running on Docker and connecting to a MySQL database in another docker container.
I have added a database connection which I know has the correct credentials since it returns the DB tables without a problem.
I have added a server action to select from one of my tables. When I execute the query it returns all the records, also without a problem.
I have added a Server Connect which attempts to utilise the above server action but when I attach a table or repeater to this I get “SQLSTATE[HY000] [2002] Connection refused”.
Without presenting the structure of your setup (e.g.: Docker container names, screenshots of the DB configuration on Wappler and relevant Server Action steps), it’s difficult for someone to provide you meaningful help. Would you be able to show more information?
For instance, the last 2 paragraphs seem contradicting, hence we need to see your Wappler steps to ensure you’re attempting to connect to the same DB, since initially you said it worked but once you added a repeater it went haywire, which doesn’t make much sense as adding a repeater shouldn’t cause such a failure behaviour
When I switch on debug I see that the 500 error is caused by “SQLSTATE[HY000] [2002] Connection refused”. This seems odd to me since I can connect to the database through (1) and (2) above.
I’m not saying it went haywire after adding a repeater. I’m saying that the database connection seems to be okay in Wappler but I’m getting a connection refused error in my browser.
Here’s some info that might help you…apologies if you already understand all this!
The database connection settings are per target. So if you can connect via one target, but not another, have a look at the connection in globals, paying close attention to the Active target selected in the editor.
There are two connection types. 1. is for the editor itself to connect, so it is from the perspective of the computer you are working on. 2. is for the server connect itself which is from the perspective of the server you are running on…again per target.
The repeater itself is not involved here, so you are correct that it is not the cause here.
To complement the post above, you’ve configured Wappler’s Database Manager correctly, but here are the settings you need to edit for the server configuration:
Show the server address, you can’t use 127.0.0.1 inside a (NodeJS?) Docker container to connect to a different (MySQL) container. If you search the forum you might find one of my replies somewhere about this issue
Okay I finally solved this. Since I’m using a Mac I’m able to use a built-in alias, namely docker.for.mac.localhost to allow me to connect to a database in another Docker container.
That wasn’t enough though. It seems that Wappler isn’t fully compatible with MySQL 8. This may be because password encryption changed in this version. So I switched to PostgreSQL and I’m back in business.