DEV Community

Mahesh Jagtap
Mahesh Jagtap

Posted on

1 1

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:
docker-compose_OLD

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:

docker-compose_Updated

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.

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay