DropVPS Team
Writer: Cooper Reagan
How to open TCP port 3306 in ubuntu 25.04

Table of Contents
What you will read?
If you’re running MySQL or MariaDB on Ubuntu 25.04 and want to allow external access, you’ll need to open TCP port 3306.
Step 1: Make Sure UFW is Installed
Ubuntu includes UFW by default, but if it’s missing, install it:
sudo apt update
sudo apt install ufw
Check its status:
sudo ufw status
If it says “inactive”, move to the next step to enable it.
Step 2: Enable UFW
Enable the firewall (if it’s not already active):
sudo ufw enable
This will start UFW without interrupting current SSH or other active sessions.
Step 3: Open Port 3306 for TCP
To allow incoming MySQL/MariaDB connections on port 3306:
sudo ufw allow 3306/tcp
This opens the port for all external IPs. To limit access to a specific IP (e.g., 192.168.1.50), use:
sudo ufw allow from 192.168.1.50 to any port 3306 proto tcp
Step 4: Verify the Rule
Check if the rule was added:
sudo ufw status numbered
You should see a rule allowing TCP traffic on port 3306.
Step 5: Ensure MySQL is Listening on External IPs
Open MySQL config file:
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
Find the line:
bind-address = 127.0.0.1
Change it to:
bind-address = 0.0.0.0
Save and exit. Then restart MySQL:
sudo systemctl restart mysql
That’s all — port 3306 should now be open and accepting remote MySQL connections on Ubuntu 25.04.