Cannot Connect to Local Database

I have install the latest on-premise version of retool in my own VPS. Everything runs smoothly aside from the part where I cannot connect to my database.

I can connect to my own database using:
psql -U user -d database

I use the IP address of the frontend network using:
docker inspect <container ID of user-postgres>

There was a point where I was able to connect only for couple of hours then I cannot connect again. Firewall is off.

Any help would greatly be appreciated.

Hey @kyou! Are you seeing any specific errors when you try connecting to your database? Would you mind sharing your container logs? :slight_smile:

Hi @victoria , thank you for your reply. Here is error log of the user-postgres_1 container:

{"log":"The files belonging to this database system will be owned by user \"postgres\".\n","stream":"stdout","time":"2023-03-09T02:33:38.933495526Z"}
{"log":"This user must also own the server process.\n","stream":"stdout","time":"2023-03-09T02:33:38.933543722Z"}
{"log":"\n","stream":"stdout","time":"2023-03-09T02:33:38.933549904Z"}
{"log":"The database cluster will be initialized with locale \"en_US.utf8\".\n","stream":"stdout","time":"2023-03-09T02:33:38.933553326Z"}
{"log":"The default database encoding has accordingly been set to \"UTF8\".\n","stream":"stdout","time":"2023-03-09T02:33:38.933556681Z"}
{"log":"The default text search configuration will be set to \"english\".\n","stream":"stdout","time":"2023-03-09T02:33:38.93356022Z"}
{"log":"\n","stream":"stdout","time":"2023-03-09T02:33:38.933563644Z"}
{"log":"Data page checksums are disabled.\n","stream":"stdout","time":"2023-03-09T02:33:38.933566703Z"}
{"log":"\n","stream":"stdout","time":"2023-03-09T02:33:38.933569825Z"}
{"log":"fixing permissions on existing directory /var/lib/postgresql/data ... ok\n","stream":"stdout","time":"2023-03-09T02:33:38.933572891Z"}
{"log":"creating subdirectories ... ok\n","stream":"stdout","time":"2023-03-09T02:33:38.933576106Z"}
{"log":"selecting default max_connections ... 100\n","stream":"stdout","time":"2023-03-09T02:33:39.070333491Z"}
{"log":"selecting default shared_buffers ... 128MB\n","stream":"stdout","time":"2023-03-09T02:33:39.229435057Z"}
{"log":"selecting default timezone ... Etc/UTC\n","stream":"stdout","time":"2023-03-09T02:33:39.337419925Z"}
{"log":"selecting dynamic shared memory implementation ... posix\n","stream":"stdout","time":"2023-03-09T02:33:39.337443902Z"}
{"log":"creating configuration files ... ok\n","stream":"stdout","time":"2023-03-09T02:33:39.361395785Z"}
{"log":"running bootstrap script ... ok\n","stream":"stdout","time":"2023-03-09T02:33:40.33289514Z"}
{"log":"performing post-bootstrap initialization ... ok\n","stream":"stdout","time":"2023-03-09T02:33:44.65198246Z"}
{"log":"\n","stream":"stderr","time":"2023-03-09T02:33:44.948844286Z"}
{"log":"WARNING: enabling \"trust\" authentication for local connections\n","stream":"stderr","time":"2023-03-09T02:33:44.948874627Z"}
{"log":"You can change this by editing pg_hba.conf or using the option -A, or\n","stream":"stderr","time":"2023-03-09T02:33:44.948879452Z"}
{"log":"--auth-local and --auth-host, the next time you run initdb.\n","stream":"stderr","time":"2023-03-09T02:33:44.948895505Z"}
{"log":"syncing data to disk ... ok\n","stream":"stdout","time":"2023-03-09T02:33:44.948908127Z"}
{"log":"\n","stream":"stdout","time":"2023-03-09T02:33:44.951989785Z"}
{"log":"Success. You can now start the database server using:\n","stream":"stdout","time":"2023-03-09T02:33:44.952002886Z"}
{"log":"\n","stream":"stdout","time":"2023-03-09T02:33:44.952006556Z"}
{"log":"    pg_ctl -D /var/lib/postgresql/data -l logfile start\n","stream":"stdout","time":"2023-03-09T02:33:44.952013105Z"}
{"log":"\n","stream":"stdout","time":"2023-03-09T02:33:44.952016194Z"}
{"log":"waiting for server to start....2023-03-09 02:33:45.204 UTC [47] LOG:  listening on Unix socket \"/var/run/postgresql/.s.PGSQL.5432\"\n","stream":"stdout","time":"2023-03-09T02:33:45.205367627Z"}
{"log":"2023-03-09 02:33:45.274 UTC [48] LOG:  database system was shut down at 2023-03-09 02:33:44 UTC\n","stream":"stdout","time":"2023-03-09T02:33:45.275246163Z"}
{"log":"2023-03-09 02:33:45.329 UTC [47] LOG:  database system is ready to accept connections\n","stream":"stdout","time":"2023-03-09T02:33:45.333090717Z"}
{"log":" done\n","stream":"stdout","time":"2023-03-09T02:33:45.365231802Z"}
{"log":"server started\n","stream":"stdout","time":"2023-03-09T02:33:45.365237742Z"}
{"log":"\n","stream":"stdout","time":"2023-03-09T02:33:45.764572623Z"}
{"log":"/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*\n","stream":"stdout","time":"2023-03-09T02:33:45.764599198Z"}
{"log":"\n","stream":"stdout","time":"2023-03-09T02:33:45.764604Z"}
{"log":"2023-03-09 02:33:45.763 UTC [47] LOG:  received fast shutdown request\n","stream":"stdout","time":"2023-03-09T02:33:45.764607579Z"}
{"log":"waiting for server to shut down....2023-03-09 02:33:45.764 UTC [47] LOG:  aborting any active transactions\n","stream":"stdout","time":"2023-03-09T02:33:45.769454851Z"}
{"log":"2023-03-09 02:33:45.797 UTC [47] LOG:  background worker \"logical replication launcher\" (PID 54) exited with exit code 1\n","stream":"stdout","time":"2023-03-09T02:33:45.798529502Z"}
{"log":"2023-03-09 02:33:45.801 UTC [49] LOG:  shutting down\n","stream":"stdout","time":"2023-03-09T02:33:45.805124406Z"}
{"log":"2023-03-09 02:33:45.856 UTC [47] LOG:  database system is shut down\n","stream":"stdout","time":"2023-03-09T02:33:45.856974572Z"}
{"log":" done\n","stream":"stdout","time":"2023-03-09T02:33:45.864119581Z"}
{"log":"server stopped\n","stream":"stdout","time":"2023-03-09T02:33:45.864812336Z"}
{"log":"\n","stream":"stdout","time":"2023-03-09T02:33:45.866556219Z"}
{"log":"PostgreSQL init process complete; ready for start up.\n","stream":"stdout","time":"2023-03-09T02:33:45.86726166Z"}
{"log":"\n","stream":"stdout","time":"2023-03-09T02:33:45.867496873Z"}
{"log":"2023-03-09 02:33:45.974 UTC [1] LOG:  listening on IPv4 address \"0.0.0.0\", port 5432\n","stream":"stderr","time":"2023-03-09T02:33:45.976540986Z"}
{"log":"2023-03-09 02:33:45.977 UTC [1] LOG:  listening on IPv6 address \"::\", port 5432\n","stream":"stderr","time":"2023-03-09T02:33:45.979275777Z"}
{"log":"2023-03-09 02:33:45.984 UTC [1] LOG:  listening on Unix socket \"/var/run/postgresql/.s.PGSQL.5432\"\n","stream":"stderr","time":"2023-03-09T02:33:45.98656764Z"}
{"log":"2023-03-09 02:33:46.092 UTC [66] LOG:  database system was shut down at 2023-03-09 02:33:45 UTC\n","stream":"stderr","time":"2023-03-09T02:33:46.092368355Z"}
{"log":"2023-03-09 02:33:46.125 UTC [1] LOG:  database system is ready to accept connections\n","stream":"stderr","time":"2023-03-09T02:33:46.1255143Z"}
{"log":"2023-03-10 04:10:47.926 UTC [1628] STATEMENT:  CREATE USER supportuser WITH PASSWORD passhere!;\n","stream":"stderr","time":"2023-03-10T04:10:47.928724373Z"}
{"log":"2023-03-10 04:12:19.680 UTC [1640] STATEMENT:  ALTER DATABASE supportdb OWNER TO supportuser;\n","stream":"stderr","time":"2023-03-10T04:12:19.680927761Z"}

docker inspect:

            "Networks": {
                "support-plus_backend-network": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "b4dd0127003c",
                        "user-postgres"
                    ],
                    "NetworkID": "cb35203f8f77c39a9db6aac036b927fc0d823716ecff7fe644523aa0b6366388",
                    "EndpointID": "bf77fd2eafbe1a70f1fc1eff28c313f0595204911a0441e6945b4f43a4dff480",
                    "Gateway": "172.20.0.1",
                    "IPAddress": "172.20.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:14:00:02",
                    "DriverOpts": null
                },
                "support-plus_db-connector-network": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "b4dd0127003c",
                        "user-postgres"
                    ],
                    "NetworkID": "efc36d27d5ceebbe8d5d14f881a12f707f265717a127c781af59d4bc6c73ce0a",
                    "EndpointID": "f3918446433bd5640016ab10c012abf358cf20d3e107ee3052cac35c7d27409f",
                    "Gateway": "172.18.0.1",
                    "IPAddress": "172.18.0.3",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:12:00:03",
                    "DriverOpts": null
                },
                "support-plus_frontend-network": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "b4dd0127003c",
                        "user-postgres"
                    ],
                    "NetworkID": "2cc717b1859123f14493db7012a8eb08bc7f2758dcfef95c51dc1d07f4bb3acd",
                    "EndpointID": "84bbe32328a2a2bd360367d5a7763b98caa1986aa6ed7ac35f92d16eae1d1df1",
                    "Gateway": "172.21.0.1",
                    "IPAddress": "172.21.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:15:00:02",
                    "DriverOpts": null
                }
            }

I used 172.21.0.2 as the host in my retool resource conf and the firewall of the ubuntu host machine is currently disabled.

Thank you for sharing that! Just to confirm, you’re trying to connect to the Retool internal DB, and not to an externally hosted DB (e.g. a MySQL DB) in a resource?

And what state is your are apps showing up? Also, what version are you on? Is your version pointed to a specific version number or is it pointed to ‘latest’?

Hi Victoria!

Yes I am connecting to an internal DB. Its the PosgresSQL which comes with the retool when I install it.

There are two postgres DB installed and I used the one with the name user_postgres

It's in a running state

Edit: The version I am using is: 2.110.3

Any update about this @victoria ?

Hey @kyou! Which docs did you follow to get set up? Just to double check, what are you seeing when you try to start up Retool? Any errors in your browser console or logs from your api-container?

And to quote another user's answer on another thread, "where are you running retool? Is it on a Linux VM? If you are using the browser on the Linux box, you can use "localhost:3000" in the browser of the VM. You may need to put the VM network adapter in bridged mode. This will cause the VM to get a separate IP address on the local network. You can either set it statically or let it get one through DHCP. Then you can access the VM's IP address on your network with: xxx.xxx.xxx.xxx:3000, where the x's are replaced with the VM IP. Hope this helps."