0

I am new to sequelize, mysql and phpmyadmin. I am trying to connect to my remote database but i get the following error:

Uncaught Exception: 500 - connect ECONNREFUSED xx.xxx.xxx.xx:xxxx, Stack: SequelizeConnectionRefusedError: connect ECONNREFUSED xx.xxx.xxx.xx:xxxx

I checked out this link and various other solution on Stackoverflow but it didnt solve my problem.

database.ts

import { Sequelize } from "sequelize";
import { DB_HOST, DB_NAME, DB_PASSWORD, DB_USER } from "../config";
export const DB = new Sequelize(DB_NAME, DB_USER, DB_PASSWORD, {
  host: DB_HOST,
  dialect: "mysql",
  logging: false,
  typeValidation: true,
  dialectOptions: {
    supportBigNumbers: true,
    bigNumberStrings: true,
  },
  define: {
    charset: "utf8mb4",
    collate: "utf8mb4_unicode_ci",
    createdAt: "created_at",
    updatedAt: "updated_at",
    deletedAt: "deleted_at",
    paranoid: true,
    underscored: true,
  },
  pool: {
    max: 5,
    min: 0,
    acquire: 30000,
    idle: 10000,
  },
});

walexy
  • 609
  • 2
  • 7
  • 16
  • are you sure that there is a mysql in your host – nbk Sep 11 '21 at 21:52
  • @nbk Yes, there is. – walexy Sep 12 '21 at 00:50
  • the error message is clearly saying with your configuration, it doesn't so check every part of the connection string host port if they are correct – nbk Sep 12 '21 at 07:13
  • This kinda looks like a firewall issue. Are you able to connect to the database in question from the computer that is running your `sequelize` code via some other means? In other words, can you connect via [MySQL Workbench](https://www.mysql.com/products/workbench/) or the [MySQL command line](https://dev.mysql.com/doc/refman/8.0/en/mysql.html) from the computer running your code? – Andrew Sep 12 '21 at 14:21
  • The problem is with your mysql server, you may have to check if it accept connection from your ip address, or grant access to any host if it is a development environment, which Operating System is your mysql server installed? – akisoft Sep 15 '21 at 09:36
  • @akisoft my operating system is ubuntu 16.0.How do i check if mysql server will accept connection from my ip address? – walexy Sep 15 '21 at 09:40

0 Answers0