Hello,
I’ve got a droplet that run ubuntu and I’ve installed mysql to it. I can reach it from my computer with SSH connection from mysql workbench, so the remote access is ok. The hostname is : 127.0.0.1
The bind address in my mysqld.cnf: 127.0.0.1
I’ve got a .net core api and I would like to use docker to run it. I made the container push to docker hub and pulled it to the droplet. When i try to run I get this error: An error occurred using the connection to database ‘’ on server ‘127.0.0.1’.
My connection string: “Server=127.0.0.1;Port=3306;Database=db;Uid=user;Pwd=pass”
i tried to server:
I don’t understand why can I connect to db from mysql workbench and cannot from .net core web api.
The .net core version is 3.1
Thank you for the answer
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi @tothtomi7,
The Localhost variable should be the Ip of your droplet, after all you are connecting to your droplet not your local computer with WorkBench.
As for the troubles with connecting, most probably, you haven’t allowed your local IP address on your droplet.
You can achieve this by executing the following two commands on your droplet
iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d XXX.XXX.XXX.XXX --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s XXX.XXX.XXX.XXX --sport 3306 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT
Where XXX.XXX.XXX.XXX is your Ip address.
If you are unsure what your IP address is, you can always check it on this website
Regards, KDSys
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.