Plesk Firewall: Set Rules Without Locking Yourself Out
Most Plesk firewall mistakes happen in the minute after you click Apply. Here is the order of work that keeps your own connection alive.
The Plesk Firewall is simple to switch on and surprisingly easy to get wrong. One rule aimed at the wrong port can close the panel on 8443, cut off SSH or stop mail for every subscription on the server, and you usually find out from the terminal that just froze. The safe approach is mostly about order: know what is listening, save a copy of the rules, change one thing, then test from a machine outside the server.
Find out what the server is exposing
Start on the server with a list of everything that is listening. This takes a few seconds and often turns up something nobody meant to publish, like a database on all interfaces or an old FTP service.
sudo ss -tulpn
An address of 0.0.0.0 or [::] means the service accepts connections on every interface. 127.0.0.1 means only the server itself can reach it, so the firewall has nothing to protect there. Compare what you see with the ports Plesk documents and decide who needs each one.
| Service | Port | Who usually needs it |
|---|---|---|
| Plesk panel | TCP 8443, UDP 8443, TCP 8880 | Admins and customers who log in. 8880 is the plain HTTP version |
| Websites | TCP 80, TCP 443, UDP 443 | Everyone |
| SSH | TCP 22 | Your team, ideally from known addresses |
| FTP | TCP 21 | Only customers who still use it |
| SMTP | TCP 25, TCP 465 | Other mail servers and your mail users |
| POP3 and IMAP | TCP 110, 995, 143, 993 | Mail users, if the server hosts mailboxes |
| MySQL or MariaDB | TCP 3306 | Often nobody outside the server |
| PostgreSQL | TCP 5432 | Often nobody outside the server |
| DNS | UDP 53, TCP 53 | The internet, if this server is authoritative for your domains |
The database rows are the usual quick win. Websites on the same machine talk to the database locally, so a public 3306 tends to serve only attackers and the one developer who set it up years ago. Check with that developer before closing it.
Check for a second firewall before you start
Plesk's firewall documentation carries a clear caution: the Plesk Firewall and firewalld both manage iptables, and using them at the same time can close ports Plesk needs. On AlmaLinux and Rocky Linux servers, firewalld is often already there.
systemctl is-active firewalld
If that prints active, pick one tool. Copy across any custom rules first, because a rule that only lives in firewalld disappears from your protection when you stop it. Containers need their own check as well. The same Plesk page notes that Docker's firewall rules are not added to the Plesk Firewall rule list, so a published container port will not appear there.
Enable the firewall and back up the rules
-
1
Install the extension
If Firewall is missing under Tools & Settings, install it from the Plesk Extensions Catalog.
-
2
Open a second SSH session
Leave it connected for the whole job. If a change goes badly, an established session is your way back in, and it costs nothing to keep open.
-
3
Confirm you have console access
Find your provider's web or VNC console now and check that it logs in. That is your route back if both SSH sessions die.
-
4
Turn it on
Go to Tools & Settings, then Firewall under Security, and set Firewall protection to Enabled.
-
5
Export the current rules
Save a copy off the server too, so a bad change is one import away from being undone.
plesk ext firewall --export > /root/plesk-firewall-$(date +%F).json
Change one service at a time
Plesk separates two ideas. Policies affect all connections to or from the server, and rules govern incoming connections to individual services. Rules override policies, which is what lets you run a strict default and still open specific ports.
To add a custom rule, use the Firewall page and set Match direction to Incoming, choose an Action of Allow or Deny, enter the port such as TCP 3306, and fill in Sources with the address or range it applies to. Save, click Apply Changes, then Apply. Nothing takes effect until that last step.
Limiting SSH or the panel to fixed addresses is one of the strongest changes you can make, and the riskiest if your office IP changes. Keep a backup route, such as a VPN address or a second known IP, in the allowed Sources. Country rules exist as well, using two-letter ISO codes, but they catch real customers who travel or use a VPN, so save them for traffic you can show you do not want.
Restore a working configuration from the command line
This is where the export pays off. Plesk's import process uses two SSH sessions on purpose: one applies the rules, and the other confirms that you can still get in. If no confirmation arrives within 60 seconds of --apply, Plesk rolls back to the previous configuration.
-
1
Session 1: enable the firewall
Run
plesk ext firewall --enable. Skip this step if the firewall is already on. -
2
Session 2: confirm it
Check that SSH still works, then run
plesk ext firewall --confirm. -
3
Session 1: import and apply
Run the import command below.
-
4
Session 2: confirm again
Open a new login to prove access, then run
plesk ext firewall --confirmbefore the 60 seconds are up.
plesk ext firewall --import -config /root/plesk-firewall-2026-11-22.json && plesk ext firewall --apply
Open a brand new SSH connection before you confirm. An existing session can survive a rule that would block the next login, so it proves very little. The exact command-line options vary by extension version, and plesk ext firewall --help lists what yours supports.
Test from outside the server
A rule that looks right in the panel is still a theory. Run the check from a laptop or another server, and from one address that should be allowed and one that should not.
for p in 22 80 443 8443 3306; do nc -vz -w 5 203.0.113.10 $p; done
Then do the human checks: load a customer site over HTTPS, log in to the panel, and send and receive a test email if the server hosts mail. Mail is the one people forget, and a closed port 25 stays quiet until a customer calls about missing messages.
What the firewall cannot see
Ports 80 and 443 have to stay open, and that is where most attacks on a hosting server arrive. A SQL injection or a flood against wp-login.php looks like permitted traffic to a port rule. Plesk covers part of this with Fail2Ban, found under Tools & Settings, IP Address Banning (Fail2Ban). Add your own addresses on its Trusted IP Addresses tab before you tighten anything. For the request layer, What Is the Best Web Application Firewall for Plesk? explains what to look for, and Plesk Server Under DDoS covers the incident itself.
BashEdge for Plesk picks up where port rules stop. It is a native extension that combines a server firewall, a WAF, application-layer DDoS protection and intrusion prevention, and it keeps your current firewall rules intact. It starts in monitor mode, so you can see what it would do to real traffic before it blocks anything.