[SOLVED] ETIMEDOUT while connecting remote mysql database from node.js app on heroku server

Issue

Example of the code I use:

const connection = mysql.createPool({
    host: process.env.NEXT_DB_HOST, //*******.timeweb.ru
    database: process.env.NEXT_DB_DATABASE, //c*****_tech
    user: process.env.NEXT_DB_USER, //c*****_tech
    password: process.env.NEXT_DB_PASSWORD, //******
    waitForConnections: true,
    connectTimeout: 100000,
    connectionLimit: 10,
    queueLimit: 0
});

connection.query(
    "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'",
    (err, results, fields) => {
         if(err) console.log(err);
         console.log(results);
         console.log(fields);
    }
);

All vars are added in heroku. Also the domain is added to timeweb panel as "Access db point". I know that heroku has dinamic IP, so how can I connect remote db?

Solution

Timeweb use only static IP-address for connecting, but heroku has dinamic. It’s better to change hosting, for node.js apps it could be any VPS such as Timeweb.

Answered By – Ксения Котикова

Answer Checked By – Willingham (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.