Docker Community Forums

Share and learn in the Docker community.

Host 'host.docker.internal' is not allowed to connect to this mysql server

Hello!
I am using Docker Desktop on Windows 10. Before installing Docker desktop, my jdbc url like below is connected to mysql successfully.

jdbc:mysql://192.168.200.51:3306/test?characterEncoding=utf8&serverTimezone=Asia/Seoul

But after installing docker desktop on windows 10, jdbc url won’t connect to mysql. And it throws the following error message.

host ‘host.docker.internal’ is not allowed to connect to this mysql server

I opened the hosts file and found the following statements are generated.

Added by Docker Desktop

192.168.200.51 host.docker.internal
192.168.200.51 gateway.docker.internal

How can my jdbc url be connected to the local mysql server with IP-adddress?
Any reply please. Thanks

Hello,

GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘password’;

Run the above command in your MySQL and try.

I’ve recreated your setup and was just adding some ENV configuration to do the trick, I’ve removed volumes section because there was no problem with it:

docker-compose.yml

version: “3”
services:
db:
image: mysql:5.7
restart: always
container_name: db
environment:
- MYSQL_ROOT_PASSWORD=rootpasswd
- MYSQL_DATABASE=phpmyadmin
- MYSQL_USER=user
- MYSQL_PASSWORD=userpasswd
networks:
- db
command: --default-authentication-plugin=mysql_native_password
healthcheck:
test: “mysqladmin ping -h localhost”
interval: 1s
timeout: 1s
retries: 60

phpmyadmin:
image: phpmyadmin/phpmyadmin:4.7
restart: always
container_name: phpmyadmin
ports:
- 8080:80
networks:
- external-net
- db
environment:
PMA_HOST: db
depends_on:
- db

networks:
external-net:
external:
name: external-net
db:
driver: bridge
Accessing PHPMyadmin with root:rootpasswd works fine.