DEV Community

Mahesh Jagtap
Mahesh Jagtap

Posted on

Solution for "error: connect econnrefused [container_ip]:3306"

Hi guys,

There are many more reasons for this error. In some, users had used wrong port for MySQL in node application, in others 3306 port was already in use etc.

But for me, it was "docker-compose.yml" file issue. FYI, I am using 3 different containers for React, Node, and MySQL.

The issue was that, I was using "image" in docker-compose file for database service like this:

It was all right, untill I used volumes in dbservice. But after using volumes in dbservice it throws the above error.

The solution was to modify the docker-compose file like this:


and then adding following to Dockerfile:

//Dockerfile start
FROM mysql
//Dockerfile end

I hope you understood the solution. If have any queries, please feel free to ask it in a comment section.

Thank You.

Top comments (0)