Answer the question
In order to leave comments, you need to log in
SequelizeConnectionError in Node.js app?
Hello comrades! Faced a strange problem, please help me figure it out.
There is a Node.js application. This application works with MySQL and PostgreSQL databases . Used the sequelize library to work with the previously mentioned databases. On the local machine (windows 10) the project works. I ran this project in a Docker container. Docker itself is on a CentOS server. The application worked for a couple of days without problems, but yesterday I noticed a problem. The application cannot connect to the MySQL database, but there are no problems connecting to PostgreSQL. As mentioned earlier, the local project connects to MySQL without any problems. I also connect without problems through the dbForge/DBeaver tools.
MySQL.js:
const Sequelize = require('sequelize');
const sequelize = new Sequelize('database_name', 'username', 'password', {
host: 'host',
dialect: 'mysql',
pool: {
max: 15,
min: 5,
idle: 20000,
evict: 15000,
acquire: 30000
},
});
sequelize.authenticate().then(() => {
console.log('Connection to database has been established successfully.');
}).catch(err => {
console.error('Unable to connect to database:', err);
});
module.exports = sequelize;
const express = require('express');
const router = express.Router();
const sequelize = require('../configurations/MySQL');
const Sequelize = require('sequelize');
const passport = require('passport');
require('../configurations/password')(passport);
router.post('/search_by_name', passport.authenticate('jwt', {session: false}, null), function(req, res) {
const token = getToken(req.headers);
if (token) {
sequelize.query("LONG SQL QUERY", {
replacements: {
name: req.body.name,
},
type: Sequelize.QueryTypes.SELECT
}).then((locations) => {
res.status(200).send(locations)
}).catch((error) => {
res.status(400).send(error);
});
} else {
return res.status(401).send({
status: false,
description: "Unauthorized"
});
}
});
Answer the question
In order to leave comments, you need to log in
Try replacing firewalld with iptables and reboot your machine. There is also a sense to refuse (for one) from userland proxy.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question