When running Appsmith locally on my machine, I’d like to connect to a local Mysql/Postgresql server. Since Appsmith is run via Docker, by default it doesn’t have access to the host machine’s ports. Hence, creating a datasource that connects to localhost:3306
or localhost:5432
doesn’t work.
What do I do?
Linux Instances
You can find the host IP via the command:
ip addr show docker0
The output will be the IP of the of the host machine for that container.
Assuming the output is: 172.17.0.4
, you can then connect to your local databases via: 172.17.0.4:3306
(Mysql) or 172.17.0.4:5432
(Postgresql)
Mac OS X & WSL
You can connect to databases on your host machine via host.docker.internal
. So, host.docker.internal:3306
(Mysql) or host.docker.internal:5432
(Postgres)
3 Likes