Production Database Issues

I have a managed production database on Digital Ocean which was created with the Wappler resource manager. The database is defined in the production target as well. But whenever I try to perform a database action on the production server then it tries to connect to my local development database from my development target. So I’m getting a connection error:

{status: "500", code: "ECONNREFUSED", message: "connect ECONNREFUSED 127.0.0.1:5435",…}
code
: 
"ECONNREFUSED"
message
: 
"connect ECONNREFUSED 127.0.0.1:5435"
stack
: 
"Error: connect ECONNREFUSED 127.0.0.1:5435\n    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1278:16)\n    at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17)"
status
: 
"500"

My production target:

Any ideas on what I could check or how to resolve this? Is this a bug?

Well seems like you have mixed the targets somehow. Make sure you production target is selected, then edit the db connection and enter the right production settings. Save and deploy.

Thanks @George
I’ve tried exactly that before and checked the target configs in the .Wappler folder as well. Everything in there looks good. But it keeps trying to connect to my local database.

Maybe that helps: Even if I delete the local development target and create the production target again from scratch then it still keeps happening.

Check the database connection settings in server connect

1 Like

Thanks so much @George! That was the issue. It’s an important project so I really appreciate that.

There is really an opportunity here to improve the UI as this is an easy mistake to make.

Wouldn’t it be nice if the Database Connections, when opened would show all targets and allow the user to change them all regardless of Active Target?

This could also be done for the entire Server Connect Settings panel as they are also target specific. This way when editing, it is readily apparent that changes made must be propagated to all targets. Right now it is very easy to make the change and not realize/remember that all targets might need updating.

In other words, no longer require a user to choose an Active target in order to change settings. Instead, have a single panel that is global for the entire project, and includes the ability to change settings for all targets in one place.

2 Likes

When the UI got reworked one of the things that was discussed was having everything as a tab instead of modals that keep getting in the way.

Having project and target settings open as a tab was mentioned but it didn’t happen.

I agree and btw thanks for your Wappler training. They helped me a lot when I started. Since you are around: I now struggle to understand why we should define a DB connection in the target settings when we need to update it in server_connect as well.

With a product that evolves so quickly, sometimes there are things that overlap.

Thanks, I just wanted to make sure that‘s the case. So in the end I should always check server connect and can basically ignore the target settings? Server Connect allows adding multiple connections as well which I needed for my project while the target doesn‘t. :sweat_smile: It‘s a little messy how all of the target specific db stuff works.

Normally when changing the target settings those should reflect also the server connect database settings. I will investigate if this happens correctly when the target is not active, seems to me that there is a problem there. Might be indeed with the new cloud database settings that not everything is passed to all targets in server connect.

Another thing you might need to check @George while you are on this: In server connect you can add the certificate for the SSL connection to a managed db. You can not add that in the target settings. Not sure if your resource manager pulls that automatically or not but the target manager should have cert options even for custom databases like the server connect db settings do.

A few more things I noticed while trying to fix this: You can add a db to a target and name it whatever-whatever but - is invalid in server connect. So if you head to server connect the db name will include the - and won‘t save unless you remove it.

I had the same issue with a db that wasn‘t created with the resource manager before never checked server connect on that one and deleted it. So I‘m not sure if this is all due to the resource manager not updating server connect.

I just checked and server connect database connection settings, when using cloud databases, should be really saved also per target as it should.

Maybe you mixed up too much when adding and deleting targets.