Question

Port 3306 blocked even though do, ufw, and iptables are configured to allow.

I am trying to remotely connect to my mysql instance and have been unsuccessful.

ufw shows port 3306 open iptables is not configured and the droplet firewall shows that it should be allowed. I have confirmed that my ip address is correct.

Please advise.

from droplet: user@host:~$ sudo ufw status [sudo] password for user: Status: active

To Action From


22 ALLOW Anywhere Apache Full ALLOW Anywhere 21/tcp ALLOW Anywhere 80 ALLOW Anywhere 443 ALLOW Anywhere 3306 ALLOW Anywhere 22 (v6) ALLOW Anywhere (v6) Apache Full (v6) ALLOW Anywhere (v6) 21/tcp (v6) ALLOW Anywhere (v6) 80 (v6) ALLOW Anywhere (v6) 443 (v6) ALLOW Anywhere (v6) 3306 (v6) ALLOW Anywhere (v6)

user@host:~$ sudo iptables -nL -V iptables v1.6.1

from DO interface:

Firewalls Default Inbound Type Protocol Port Range Sources SSH TCP 22 x.x.x.x HTTP TCP 80 All IPv4 All IPv6 HTTPS TCP 443 All IPv4 All IPv6 MySQL TCP 3306 x.x.x.x Outbound Type Protocol Port Range Destinations ICMP ICMP All IPv4 All IPv6 All TCP TCP All ports All IPv4 All IPv6 MySQL TCP 3306 All IPv4 All IPv6 All UDP UDP All ports All IPv4 All IPv6


Submit an 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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
June 17, 2020
Accepted Answer

Hi there @damianyates,

It sounds like that your MySQL service might be binding only on 127.0.0.1:3306 and if you want to access MySQL from the outside world, you need to change this to 0.0.0.0:3306.

To check if this is the case you can run the following netstat command:

  1. netstat -plant | grep 3306

If this is the case, I would recommend following the steps here on how to change that:

https://www.digitalocean.com/community/tutorials/how-to-allow-remote-access-to-mysql

Hope that this helps! Regards, Bobby

PEBKAC - I forgot to restart the sql service after making that change earlier. Thank you so much.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.