Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

207
Views
trying to connect to the xampp database, but having issue code: 'ECONNREFUSED', errno: -111,

i've been trying to connect to to the xampp database with the following code:

async function connect(){
    
if (global.connection && global.connection.state !== 'disconnected')
        return global.connection;

    const mysql = require("mysql2/promise");
    const connection = await mysql.createConnection("mysql://root:root@localhost:3307/crud-almir-lp");
    console.log("Connected in mysql!");
    global.connection = connection;
    return connection;
}
connect();

module.exports = {}

But every time I try to connect to the database, it returns the error:

    /mnt/c/xampp/htdocs/crud-almir-lp/node_modules/mysql2/promise.js:242
  const createConnectionErr = new Error();
                              ^

Error: connect ECONNREFUSED 127.0.0.1:3307
    at Object.createConnection (/mnt/c/xampp/htdocs/crud-almir-lp/node_modules/mysql2/promise.js:242:31)
    at connect (/mnt/c/xampp/htdocs/crud-almir-lp/js/db.js:6:36)
    at Object.<anonymous> (/mnt/c/xampp/htdocs/crud-almir-lp/js/db.js:11:1)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/mnt/c/xampp/htdocs/crud-almir-lp/js/index.js:1:12) {
  code: 'ECONNREFUSED',
  errno: -111,
  sqlState: undefined

I tried to add a new password at the database, use express, sequelize, but the error continues. I've also tried to change the defaul port of xampp to 3307, as i show below, but im still having the same error. How to proceed?

Im calling the function in another archive like this:

const db = require('./db');
console.log('Start!');
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!