[SOLVED] SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:3306

Issue

I’m using Sequelize as an ORM to my node js app and Mysql database ,
after following some tutorials i m adding this code to connect mysql to the node but after taping npm start i m getting this error :
Unable to connect to the database: { SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:3306

 const Sequelize = require('sequelize');

 // Option 1: Passing parameters separately
 const sequelize = new Sequelize('Education', 'root','', {
 host: '127.0.0.1',
 dialect: 'mysql'
 } );

  //test db 
 sequelize
.authenticate()
.then(() => {
  console.log('Connection has been established successfully.');
})
 .catch(err => {
 console.error('Unable to connect to the database:', err);
});

Solution

Problem solved i was using port : 3307 in phpMyadmin instead of 3306

Answered By – Anas Zayene

Answer Checked By – Terry (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.