Connecting to MySQL from Flask Application using docker-compose

Change this

return mysql.connector.connect(user='testing', host='0.0.0.0', port='3306', password='testing', database='test')

to

return mysql.connector.connect(user='testing', host='mysql', port='3306', password='testing', database='test')

Your code is running inside the container and not on your host. So you need to provide it a address where it can reach within container network. For docker-compose each service is reachable using its name. So in your it is mysql as that is name you have used for the service