Get error connect ECONNREFUSED 127.0.0.1:3306 when start my node.js app

12,560

Solution 1

I found a problem! In my mysql config file (etc/my.cnf) was bind-address = my VPS ip So, when I remove this line it starts to listen al ips.

Thanks every one!

Solution 2

Try restarting the MySQL service.

Share:
12,560
Nastro
Author by

Nastro

Updated on June 14, 2022

Comments

  • Nastro
    Nastro almost 2 years

    When I start my node.js app I get this error:

    SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:3306
    

    What I was doing:

     - create a user:
    CREATE USER 'main'@'localhost' IDENTIFIED BY 'myPass';
    
     - give this user all privileges
    GRANT ALL PRIVILEGES ON *.* TO 'main'@'localhost' WITH GRANT OPTION;
    FLUSH PRIVILEGES;
    

    I then try to connect through my code on production and it gives me an error: connect ECONNREFUSED 127.0.0.1:3306.

    But in my localhost environment it connects well. And when I try to connect to DB using command line on VPS it works too: mysql -umain -p

    I can't connect with code. But on my localhost it connects. Double checked my loggin and pass for DB user in .env.