SequelizeConnectionRefusedError 节点Js mysequlize

SequelizeConnectionRefusedError nodeJs mysequlize

提问人:Engr.Aftab Ufaq 提问时间:10/31/2023 更新时间:10/31/2023 访问量:18

问:

我有两个 cpanels cpanel1 和 cpanel2 。在 cpanel1 上,我有 1 个 MySQL 数据库,我想从 cpanel2 访问它。

在本地开发(Windows 和 macOS)上一切正常。我已成功连接并获取数据。

但是当我关闭我的 nodeJS 服务器时。它给了我这个错误

{\"name\":\"SequelizeConnectionRefusedError\",\"parent\":{\"errno\":-111,\"code\":\"ECONNREFUSED\",\"syscall\":\"connect\",\"address\":\"95.217.67.74\",\"port\":3306,\"fatal\":true},\"original\":{\"errno\":-111,\"code\":\"ECONNREFUSED\",\"syscall\":\"connect\",\"address\":\"95.217.67.74\",\"port\":3306,\"fatal\":true}} 

在 cpanel 1 上,我将所有 IP 地址列入白名单,例如 %.%.%.%、192.%、0.0.0.0、192.68.%,但仍然无法连接到这些地址。

这是我的代码。

const express = require("express");
const router = express.Router();
const remoteDb = require("../_helpers/remoteDb");
// routes
router.post("/", checkFunction);
router.get("/", checkFunction);
router.get("/", checkFunction);
router.put("/", checkFunction);
router.delete("/", checkFunction);
module.exports = router;

async function checkFunction(req, res, next) {
    try {
        const results = await remoteDb.query(
            `SELECT id,country_id as countryId ,mobile_number as nationalNumber ,name as personName FROM table_name WHERE 1 LIMIT 100 OFFSET 1`
        );
        res.send(results[0]);
    } catch (err) {
        res.send({
            status: false,
            data: null,
            errorMessage: JSON.stringify(err),
        });
    }
}

在 localhost(Windows 和 macOS)上,我能够获取数据。但是当我在另一台服务器上部署时,我遇到了错误。

请帮帮我。现在已经 3 天了。并有同样的问题。

WHM 上的 cPanel 和我都以 WHM 为根访问权限。

我已经阅读了这些问题,但它们都无法回答我 question.it 不关闭这个问题的请求。

任务 1

任务 2

任务 3

任务 4 任务 5 任务 6

MySQL的 node.js sequelize.js

评论

0赞 Anatoly 11/1/2023
您是否设法使用相同的参数从外部连接到?cpanel1
0赞 Engr.Aftab Ufaq 11/3/2023
是的。我工作得很好
0赞 Engr.Aftab Ufaq 11/3/2023
我终于解决了。这是由于 cpanel2 的安全规则不允许连接到任何其他服务器。修复它。谢谢@everyone

答: 暂无答案