Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk9 min

How to Disable Remote Access to MySQL on Your VPS

Set MySQL to listen on 127.0.0.1, restart it, deny TCP 3306 at every firewall layer, and verify local and external connection behavior without breaking your application.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To make MySQL local-only on an Ubuntu VPS, set bind-address = 127.0.0.1 in /etc/mysql/mysql.conf.d/mysqld.cnf under [mysqld], restart MySQL, and deny inbound TCP port 3306 in both the VPS firewall and any provider security group. Verify with sudo ss -lntp | grep mysql: a local-only server should show 127.0.0.1:3306, not 0.0.0.0:3306 or [::]:3306.

What disabling remote MySQL access actually changes

MySQL accepts TCP connections on the network addresses configured by its bind_address setting. Binding to 127.0.0.1 restricts TCP connections to the VPS loopback interface, so another machine cannot reach the MySQL listener through the server’s public or private network interfaces. Oracle’s MySQL documentation describes this as accepting TCP/IP connections only through loopback.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This is separate from MySQL authentication. A username and password can be perfectly valid while a remote connection is impossible because no network path reaches the listener. It is also separate from Unix-socket access: applications running on the VPS can continue using the local socket even when remote TCP access is disabled.

Disabling the listener is a useful default when the website, API, or other database client runs on the same VPS. It reduces the exposed attack surface and removes the need to maintain remote database credentials and firewall exceptions. It does not replace strong database passwords, least-privilege accounts, operating-system updates, or provider-level network controls.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Before you change anything

Confirm where the application runs

Local-only binding is appropriate when every MySQL client is on the same VPS. If an application server, worker, reporting host, desktop tool, or backup service connects from another machine, changing the bind address will interrupt it. Identify those clients first and decide whether they can move to a local socket, an SSH tunnel, a VPN, or a private interface.

Keep a recovery session open

Use an existing SSH session while making the change and open a second session if possible. A configuration error can prevent MySQL from restarting, and a firewall mistake can cut off a remote administration path. Do not close your working shell until the service status, listener, application, and firewall rules have all been checked.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Record the current state

Save the current configuration and listener output so you can compare the result or restore the previous setting if a dependency was missed.

sudo cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/mysql.conf.d/mysqld.cnf.backup
sudo ss -lntp | grep -E 'mysql|3306'

The ss command may show one of these patterns:

  • 0.0.0.0:3306 means MySQL is listening on all IPv4 interfaces.
  • [::]:3306 means it is listening on all IPv6 interfaces.
  • 127.0.0.1:3306 means IPv4 TCP access is limited to the VPS itself.
  • A private address such as 10.x.x.x:3306 or 192.168.x.x:3306 means it is listening on that interface; the exact address and firewall policy determine who can reach it.

Step 1: Inspect the current MySQL listener

Run the following as a user with sudo access:

sudo ss -lntp | grep -E 'mysql|3306'

If the command returns no line, MySQL may be stopped, may use a different port, or may be using only a Unix socket. Check the service before editing:

sudo systemctl status mysql.service --no-pager

A wildcard address is the important warning sign. A process listening on 0.0.0.0:3306 or [::]:3306 can receive traffic arriving through any interface that the firewall permits. The listener output is more reliable than assuming a firewall rule is protecting the service, because it shows what MySQL itself has opened.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Step 2: Bind MySQL to loopback

Edit the Ubuntu package configuration

For the standard Ubuntu package installation, open:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudoedit /etc/mysql/mysql.conf.d/mysqld.cnf

Find the [mysqld] section. Add or change the setting there:

[mysqld]
bind-address = 127.0.0.1

Use one active bind-address line. If the file contains a commented example beginning with #, add an uncommented line rather than leaving two competing active values. Keep the spelling and section name exactly as shown. The option is a startup setting, so saving the file does not change the running listener until MySQL is restarted.

Why not use a wildcard address?

0.0.0.0 deliberately listens on every IPv4 interface; it is the opposite of a local-only configuration. An IPv6 wildcard such as :: can expose the service over IPv6 even if an IPv4 rule appears safe. If local-only access is the goal, loopback binding is clearer and less dependent on firewall behavior.

Step 3: Restart MySQL and inspect the result

Apply the startup setting with:

sudo systemctl restart mysql.service

Immediately check that the service is active and that the listener changed:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
sudo systemctl status mysql.service --no-pager
sudo ss -lntp | grep mysql

The expected TCP result is a loopback listener such as 127.0.0.1:3306. If MySQL also displays an IPv6 loopback listener, it should be limited to ::1:3306, not [::]:3306. A Unix-socket file may appear separately; that is normal and allows local applications to continue connecting through the socket.

If the restart fails

Do not repeatedly restart a service that is reporting a configuration error. Read the systemd journal:

sudo journalctl -u mysql

Look for a misspelled option, a setting placed outside the [mysqld] section, an invalid address, or a syntax error in the option file. The address must belong to the VPS. If you accidentally entered an address that is not configured on an interface, MySQL can fail to bind and refuse to start. Restore the backup if necessary, restart, and then reapply a corrected loopback setting.

Step 4: Deny TCP 3306 in UFW

Binding to loopback prevents remote connections at the MySQL layer. A firewall rule is still valuable as defense in depth and prevents a later configuration change from silently reopening the public path. Ubuntu identifies UFW as its default firewall configuration tool.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Review existing rules first

sudo ufw status numbered

Look for broad rules that allow 3306/tcp, including rules that permit it from anywhere. Remove an unnecessary broad allow by its rule number, then add an explicit deny:

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
sudo ufw delete <rule-number>
sudo ufw deny 3306/tcp
sudo ufw status numbered

Replace <rule-number> with the number shown by your own status output. Do not delete a rule by guessing its number; UFW renumbers entries after deletions. If UFW is inactive, the deny command will not provide protection until the firewall is enabled and configured without locking you out of SSH.

Check the provider firewall too

Many VPS platforms have an external firewall, security group, or network ACL in addition to UFW. Remove inbound TCP 3306 permits there, or set an explicit deny if the platform supports it. A cloud rule can expose the port even when the operating-system firewall is permissive, and a provider rule can remain open after a local rule is changed. Review both layers whenever you change database exposure.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Step 5: Test local and remote behavior

Test from the VPS

Use the same connection method your application uses. A local Unix-socket connection can continue to work after remote TCP is disabled. To test local TCP explicitly, specify the loopback host:

mysql -h 127.0.0.1 -u <user> -p

Replace <user> with the database account used for the test. A successful login confirms that MySQL is accepting local TCP connections; it does not prove that the firewall is correct for external traffic.

Test from another host

From a machine outside the VPS, test TCP reachability to the VPS address and port 3306 using the TCP testing utility available on that machine. The expected result is a refusal or timeout, depending on which layer drops the packet. If a remote client reports an authentication error, it reached MySQL and the problem is credentials, account host permissions, or TLS policy rather than a blocked listener. If it cannot connect at all, inspect the listener and both firewall layers.

MySQL’s troubleshooting guidance recommends checking the server’s listening address and firewall or iptables rules when diagnosing connection failures. Treat those checks as separate questions: is a process listening, is a route allowed, and only then does MySQL authentication succeed?

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When skip_networking is a better fit

MySQL also provides the skip_networking option. It disables TCP/IP networking entirely, while local Unix-socket access can remain available. This is stricter than binding to 127.0.0.1: local TCP clients that explicitly use 127.0.0.1 will no longer work, even though applications using the Unix socket may continue to function.

Choose skip_networking only after checking how every local client connects. It is useful when you want to eliminate TCP altogether, but it can break scripts or applications that run on the same VPS and force a TCP host. Add it under [mysqld], restart MySQL, and verify the resulting socket-based behavior. For most single-server web stacks, loopback binding is the less disruptive local-only setting.

If another machine genuinely needs MySQL

Do not bind to a public wildcard merely to make a multi-host application work. Bind MySQL to the specific private IPv4 or IPv6 address used by the application network. Oracle’s secure-deployment guidance states that a specific address limits TCP/IP acceptance to that address.

Choose the narrowest network exposure

Design MySQL bind address Firewall source Transport Operational trade-off
Same-host application 127.0.0.1 Deny inbound 3306 Unix socket or local TCP Lowest exposure and simplest maintenance
Private application network Specific private interface address Only the application host or private subnet Private network; add TLS where required Supports separate hosts without public exposure
Administrative or occasional remote access Loopback, reached through a tunnel Allow SSH or VPN, not public 3306 SSH tunnel or VPN Extra setup, but the database port stays off the public interface
Public-interface database Public address or wildcard Strict source allow-list and provider rule TLS and hardened authentication Highest exposure and ongoing security burden

Restrict the source as well as the destination

A private bind address does not automatically make the service safe. Permit TCP 3306 only from the known application host or private subnet in UFW and the provider firewall. Avoid a rule that allows the entire internet. If the application topology changes, update the address and source rule together, then repeat the listener and remote tests.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a tunnel for occasional access

An SSH tunnel or VPN can provide temporary administrative access while MySQL remains bound to loopback. The exact command depends on the SSH account, local port, VPS address, and network topology, so document those values for your environment rather than exposing 3306 publicly. Close temporary tunnels when the task is complete and keep the normal firewall policy closed.

Troubleshooting by symptom

The application on the VPS stopped connecting

  • Check whether it uses a TCP host such as 127.0.0.1 or a Unix socket.
  • If skip_networking was enabled, remove it or change the client to use the socket.
  • Confirm the application account and database name were not changed; the bind-address edit does not alter them.
  • Check sudo systemctl status mysql.service --no-pager and the service journal.

MySQL will not restart

  • Read sudo journalctl -u mysql for the first configuration or bind error.
  • Confirm the setting is under [mysqld] and that only one active bind address is defined.
  • Verify that the address belongs to an interface on the VPS; use 127.0.0.1 for a universal local-only configuration.
  • Restore /etc/mysql/mysql.conf.d/mysqld.cnf.backup if you need to recover service quickly, then restart and correct the file.

The listener still shows a wildcard address

  • Check that you edited the option file used by the installed package, not a similarly named copy.
  • Search the MySQL configuration directories for another active bind-address setting and remove the conflict.
  • Restart the service after every change; this option is read at startup.
  • Check whether another MySQL-compatible service is listening on port 3306.

Remote clients still appear to connect

  • Re-run sudo ss -lntp | grep -E 'mysql|3306' and verify the address is not wildcard or public.
  • Confirm the test is really using TCP 3306 and not an SSH tunnel, VPN, port-forward, or local proxy.
  • Review UFW and the provider security group for stale allow rules.
  • Check whether a different database host or port is configured in the client.

A remote test times out, but the application is broken

A timeout from outside is consistent with a successful restriction; it does not diagnose local application configuration. Test locally with the application’s intended connection method, then inspect its own logs and credentials. Network blocking and authentication failures must be treated as separate troubleshooting branches.

Change-management checklist

  1. List every MySQL client and determine whether it is local or remote.
  2. Back up /etc/mysql/mysql.conf.d/mysqld.cnf and record the current listener.
  3. Set bind-address = 127.0.0.1 under [mysqld] for a single-host application.
  4. Restart with sudo systemctl restart mysql.service.
  5. Check service status, the journal if needed, and sudo ss -lntp | grep mysql.
  6. Remove broad TCP 3306 allows, add sudo ufw deny 3306/tcp, and verify with sudo ufw status numbered.
  7. Close provider-level 3306 permits.
  8. Test the application locally and test TCP 3306 from a separate host.
  9. Document the final bind address, firewall decision, socket path if used, and rollback file.

Final verification

The change is complete when MySQL is active, the listener is restricted to loopback, local application access works, inbound TCP 3306 is denied in UFW and the provider firewall, and an external TCP test cannot reach the database. If a separate host must connect, replace the loopback design with a specific private bind address and source-restricted rule rather than reopening the public interface.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.