Streamlit doesnt connect to mysql

Hi! I recently created a script to connet to mysql db and show some data.
now when I run the script throught the terminal everything works great, but when I add the same script and try to run it through the streamlit cloud service I get a refused connection error.
I have made a requirments.txt aswell as added the server info to the secret file, aswell as changed the config file for the mysql server, yet still it won’t connect.
maybe someone has had this problem before? any information will help, thanks :slight_smile:

Hi @Jordistyd, welcome to the Streamlit community!

Where is the mysql database located, on another cloud service or your local computer?


Hi Randyzwith, I am having the exact problem and the MySQL database is located on my local computer

Hi @Lawrence_Krukrubo -

It’s all the same problem, in that in nearly 100% of cases, you don’t want to expose your personal computer to the larger internet. Most internet service providers (at least in the U.S.) don’t even provide an easy way to open a port to allow outside traffic to access a local database.

The proper solution is to host the database on public infrastructure of some sort, whether that’s Heroku, Amazon Web Services, DigitalOcean, etc.


1 Like