Django database connection:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'baby',
'USER': 'root',
'PASSWORD': 'Thinkonce',
'HOST': 'host.docker.internal',
'PORT': '3306',
'OPTIONS': {
'charset': 'utf8mb4',
"init_command": "SET foreign_key_checks = 0;"
},
}
}
docker-compose file
version: "3"
services:
web:
# network_mode: "host"
container_name: antiquely
build: ./
# command: python manage.py runserver 0.0.0.0:8000
command: "bash -c 'python manage.py runserver 0.0.0.0:8000'"
working_dir: /usr/src/antiquely
ports:
- "8000:8000"
volumes:
- ./:/usr/src/antiquely
watcher:
container_name: watcher
build: ./
command: "bash -c 'python watcher/app.py'"
working_dir: /usr/src/antiquely
volumes:
- ./:/usr/src/antiquely
links:
- web
celery:
build: ./
command: celery -A settings worker -l info
volumes:
- ./:/usr/src/antiquely
links:
- web
- redis
# redis
redis:
image: redis
environment:
- ALLOW_EMPTY_PASSWORD=yes
ports:
- "6379:6379"
Here is my database connection and docker-compose file for django application. I am trying to connect with my locally installed mysql database
watcher | django.db.utils.OperationalError: (2005, "Unknown MySQL server host 'host.docker.internal' (-2)")
I am getting this error
Please have a look how can i fix it ?