Wappler Version: 6.3.3
Operating System: macOS Apple Silicon
Server Model: NodeJS
Database Type: Postgres
Hosting Type: Localhost
Expected Behavior
Wappler should be able to connect to a localhost Postgres database, just as it does with any other local database.
Actual Behavior
I’m uncertain if this issue is related to Wappler or Supabase. I am using a locally hosted Supabase environment, which facilitates pushing changes to the production environment. This setup is also utilized for mobile profiles via PostgREST in Flutter. Tools like Table PLUS and the terminal can successfully connect to the database. Additionally, the Wappler Database Manager can connect to, edit, and view the database, demonstrating the capacity for direct database connections.
However, when the project is launched, and the application attempts to query data from the database, the browser displays the following error code:
`{
"status": "500",
"code": "ECONNREFUSED",
"message": "connect ECONNREFUSED 127.0.0.1:54322",
"stack": "Error: connect ECONNREFUSED 127.0.0.1:54322\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1278:16)"}
Note: The database runs on port 54322 in a Docker environment. As previously mentioned, other means of connection work flawlessly, including the Wappler Database Manager.
Unfortunately, I couldn’t find any logs related to failed connection attempts in the Docker logs.
However, with pg_bouncer enabled, I receive the following logs:
`... 2024-03-21 12:16:08 2024-03-21 12:16:08.723 UTC [1] LOG S-0xaaaad285e390: [postgres/pgbouncer@172.18.0.2](mailto:postgres/pgbouncer@172.18.0.2):5432 new connection to server (from 172.18.0.13:45590)
and finishing with
`...[many of previously] 2024-03-21 12:16:40 2024-03-21 12:16:40.045 UTC [1] LOG C-0xaaaad285ad00: postgres/postgres@172.18.0.1:51448 closing because: client close request (age=0s)
There are numerous connection attempts when trying to query the database, followed by client close requests shortly thereafter.
I encountered the same issue when connecting to the production database during the transition to Supabase; however, using a pooler fixed the issue. Currently, Supabase Cloud is employing Supavisor instead of pg_bouncer for pooling database connections in the locally hosted environment. Therefore, I cannot reproduce the same fix within local environment.
I have tried various configurations within pg_bouncer, including changing modes between transaction and session, increasing the maximum pool size and max client connections, and even disabling pg_bouncer, as it’s a localhost environment. Unfortunately, none of these measures have helped. I am curious whether Wappler connects to the database differently, resulting in a large number of connections being made at once. Has anyone else encountered this issue within Wappler?
Thank you!