Error while connecting to local MySQL from electron app

Hi there,

I am trying to connect to local MySql server installed on my windows from electron app using mysql2

When I try to connect, It returns ETIMEOUT error.

errorno: "ETIMEDOUT"
fatal: true
syscall: "connect"
message: "connect ETIMEDOUT"

Here is my code:

// MySql.js
import mysql from ‘mysql2’

export default class Mysql {
constructor() {
this.pool = mysql.createPool({
host: ‘’,
port: 3306,
user: ‘root’,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0
getVersion() {
    this.pool.query("select version() as version", function (err, rows, fields) {
        console.log({err, rows, fields})

Code that run on button click

new Mysql().getVersion()

This is my preload.js that expose MySql to renderer

import Mysql from “@/core/database/clients/Mysql”;


window.Bridge = {

If I run the same code with node from command line, it works fine But I doesn’t work from electron

I am new to electron and node. Can you please help me figure out what I am missing ?

If it’s working successfully at the command line it would seem you may have the node version of the MySQL module installed not the electron version - see for instructions on recompiling the node module for electron if no prebuilt binary is available.