Remote target local database connection without docker for nodejs project

I have nodejs project with xampp serving local database (mysql/mariaddb) for local development target. And a custom remote host (VPS) setup with nodejs /nginx /mariadb -phpmyadmin access as a remote target.

Local target works fine with its localhost database connection. But remote target development server is not communicating with its localhost mysql/mariadb on remote host.

Both local target and remote target databases are hosted on localhost:3306 and both has same database and users with tables and data.

I turned on server connect debug and ran published to server and ran the nodejs app ( after a bit of troubleshooting) reached following error;

server-connect:server Got error? Error: connect ECONNREFUSED ::1:3306
server-connect:server at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16)
server-connect:server --------------------
server-connect:server at Protocol._enqueue (/var/www/app/node_modules/mysql/lib/protocol/Protocol.js:144:48)
server-connect:server at Protocol.handshake (/var/www/app/node_modules/mysql/lib/protocol/Protocol.js:51:23)
server-connect:server at Connection.connect (/var/www/app/node_modules/mysql/lib/Connection.js:116:18)
server-connect:server at /var/www/app/node_modules/knex/lib/dialects/mysql/index.js:66:18
server-connect:server at new Promise ()
server-connect:server at Client_MySQL.acquireRawConnection (/var/www/app/node_modules/knex/lib/dialects/mysql/index.js:61:12)
server-connect:server at create (/var/www/app/node_modules/knex/lib/client.js:247:39) {
server-connect:server errno: -111,
server-connect:server code: ‘ECONNREFUSED’,
server-connect:server syscall: ‘connect’,
server-connect:server address: ‘::1’,
server-connect:server port: 3306,
server-connect:server fatal: true
server-connect:server } +0ms

While this could be due to one of many reasons, I would like to know if there is a deferent approach that would not result in all these troubles. I would like my app on web host to connect to local database on the same host without docker. I guess this should be a simple matter of right configurations. I appreciate any help on this given the word ‘docker’ is not used. :)…

NodeJS attempting to connect to localhost through IPv6. Is MySQL/MariaDB configured to listen on IPv6? Or is it only binding to 127.0.0.1 (IPv4)?

Apple, after seeing the line you quoted from me, I thought the same. But when I checked all configuration files for mariadb the bound address already given as localhost. Additional entries in other possible files e.g my.cnf etc had no effect.

This is how I was able to resolve the issue: I checked on phpmyadmin the database users and removed access to all users except from localhost. Also there were multiple root accounts which I reduced to 1 with localhost access. Then I updated wappler to 4.5.1 and published the project.