mysqlnode.jsdeploymentsequelize.jsrailway.js

ConnectionError [SequelizeConnectionError]: connect ETIMEDOUT sequelize deploy on railway


I am trying to deploy my app using Nodejs, MySQL with sequelize as ORM on railway platform. But I saw this error: ConnectionError [SequelizeConnectionError]: connect ETIMEDOUT at ConnectionManager.connect (/workspace/node_modules/sequelize/dist/lib/dialects/mysql/connection-manager.js:102:17) at processTicksAndRejections (node:internal/process/task_queues:96:5) ... my database config like this:

const Sequelize = require('sequelize');
const path = require('path');
require('dotenv').config({path: path.join(__dirname, '../','.env')});

const sequelize = new Sequelize(process.env.DB_DATABASE, process.env.DB_USER, process.env.DB_PASS, {
    dialect: 'mysql',
    host: process.env.DB_HOST,
    port: process.env.DB_POST,
}, {
    define: {
       freezeTableName: true, 
    }
});
module.exports = sequelize;

Solution

  • Set NODE_ENV environment variables in .env files.