connection.js
let mysql = require('mysql2'); let pool = mysql.createPool({ host:'localhost', user: 'root', database: '', password: '', connectionTimeout: 10000 }).promise() pool.getConnection(function(err, connection) { console.log('connected to database') }); pool.on('error', function(err) { console.log(err.code); }); module.exports = { getConnection: () => { return pool.getConnection() } }; other_file.js
router.get('/', async (req, res) => { const conn = await connWrapper.getConnection(); let [courses] = await conn.execute('SELECT * FROM courses'); courses = courses; //database stuff here and page rendering etc }); If I load the page for the first time, it works, however after just a few seconds it stops working and the page won't load anymore, that even if I remove connectionTimeout. Also, how come that I do not receive logs from pool.getConnection and pool.on('error'). There aren't logs in the console whatsoever.