[Fixed]-Django.db.utils.OperationalError: (2002, "Can't connect to MySQL server on 'db' (115)")

13👍

your WEB containers starts before the DB is up and running , you need to wait for it using one of these methods or starting your DB first manually with docker-compose up db

👤LinPy

3👍

Make sure that your db docker image is running fine. Check the logs of the running db container. I am able to use MariaDB successfully in my docker-compose file :

db:
image: mariadb
ports:
  - 3306:3306
environment:
  MYSQL_USER: "****"
  MYSQL_PASSWORD: "****"
  MYSQL_DATABASE: "*****"
  MYSQL_RANDOM_ROOT_PASSWORD: "yes"

0👍

A bit late for the party but if you are connecting to port 33060 change to port 3306.

Took a whole hour to recognize it exposes two ports.

👤phacic

Leave a comment