How to connect two apps to the same docker database?

Hi everyone, hope you're doing great!

I've an app finished and running locally in wappler (soon live) and now i need to connect the same database under that application to a second app that's being developed also in wappler, with the same technology (node.js and docker) the difference is that this second app doesn't need a database but it needs to retrieve information from the app #1 to be showed in the frontpage.

It needs to be this away because each app will be in a different subdomain app.domain.com and app2.domain.com

Is that possible, if so, how can i do it?

That's the config of both apps:

Application #1

Application #2

Docker containers:

Thanks in advanced!

You can create as many database connections are you're please :slight_smile:
If your dockerized database is created via wappler, you will have it available in cloud databases, else, you can alwasy add custom database via url parameters, or refresh your server (from the resource manager, and it will appear on your cloud resource list)

In addition, if database and the application are within the same docker network, container name and port can be used! :slight_smile:

Simply add connection in database manager and when selecting Database Query or other database component, simply setect that database as the connection target! :slight_smile:

Hi @Evaldas thanks for your replie!

I was able to connect to the database via a custom connection as you can see in the image bellow:


However, when i created the api, querying that database in the frontend i've got a error 500:

Yes i've created the database via wappler using docker, but it doesn't appears in the cloud services, i've tried to update the resourses but got the same result:

Captura de tela 2025-05-12 163033

Thanks in advance!

I am theorizing here; wouldn't it be as simple as configuring the server connections, in app 2, to the API endpoints of the first app?

Hi @ben but if i'm running the second app in wappler the first one is offline, so i can't access that endpoint right?

This is the connection file of both apps, i've tried using only the port 5432 but didn't work either

If creating a new database, you should be able to create database as simple as this:

If connecting to existing one, you need to bare one thing in mind, if database is dockerized you HAVE to connect it to the same network as your other project!

Meaning, if your database is within the same stack as application no.1, but the application no.2 is in the different one, it will not connect via localhost. What you need to do is, connect your applciation 2 to the same network as your application no.1 and use db as host and 5432 as port.

You can attach your project to another network via portainer.

My portainer installation failed due to already existing instance running on my system. But once installed you can easily access it via localhost:9000.
There you will ahve to create your account and you can easily manage your containers thereafter.

This applies to a lot of dockerized instances, hency why your database can be easily accessible via database management softwares via 127.0.0.1 and your app can't

1 Like

That is true for the local environment, but not when the apps are live.

You could always go live with the first app and point to those endpoints for the second app in development, much like you would do for third party API's.

If I'm not mistaken you can now run different Wappler projects at the same time, you just have to use different ports. Were you aware of that possibility?

1 Like

Hi Jonathan,

I have two projects (two wappler apps running on two separate domains) that are connected to one central database. The database is hosted on a remote server, so that it can be accessed independently by both apps in production environment.

Once a database has been setup on a remote server, import the database server under Cloud Providers in Resources Manager, and then select the database cloud server in the database connections to connect.

This is an example of how database connection has been setup in both apps. The connection is using the cloud database and database server that has been imported in the Resources Manager. The database port and credentials will be same in both apps.

1 Like

You can check the docs about how to use the same database for multiple projects:

1 Like

I don't see a reason to repeat the API from app #1, it just means having to update twice. That is why I suggested to use the API endpoint for the second app.

1 Like

Thanks for all the replies, from your suggestions i'll be looking for the best approach for this today.

Hi @ben, that's the idea but my app is offline so i thought the only way around would be connecting to the same database, because i can't access the data return from the #1 if it's offline, i may have to put it online to have access to the endpoints.