Unable to access host's localhost from container

I missed a crucial detail: I seem to have skipped the first line and assumed mysql is running on the host.

Why would you want to use the published host port to access the database from another container?
The intended approach is to put the app container and database container in the same user defined network, then use dns-based service discovery to communicate from the app container to the database container.

The networks internal dns, will resolve the service name (docker compose only), container name, container’s hostname, or the container’s network alias to the current container ip, so you will be able to reach the application in the target container with either one of those names and the container port of the application.

This does not work with default bridge network.