but it gets stuck when trying to establish a connection to the MySQL Database.
No. It gets stuck trying to connect to the server where the database is running. It doesn't attempt to connect to the database until after it connects to the server.
Is your server accepting connections on port 3306? Is your server address correct?