About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
If a port you added with firewall-cmd works until the server reboots, or until someone runs firewall-cmd --reload, the rule was added to the runtime configuration only. The firewall-cmd manual says "Without the --permanent option, a change will only be part of the runtime configuration." A reload or reboot rebuilds the runtime configuration from the permanent one, so the rule is gone. Add it again with --permanent, then reload.
What the symptom means
firewalld has two configurations. The firewalld documentation describes the runtime configuration as "the actual effective configuration and applied to the firewall in the kernel", and says "Changes in the runtime configuration are not automatically saved to the permanent configuration."
Three events replace the runtime configuration with the permanent one:
- At service start, "the permanent configuration becomes the runtime configuration".
- A service stop loses the runtime configuration.
- A reload replaces it. The Runtime versus Permanent page says "A firewalld reload will replace the runtime configuration by the permanent configuration." The firewall-cmd manual's
--reloadentry says "all runtime only changes done until reload are lost with reload if they have not been also in permanent configuration."
The permanent configuration "will be loaded and become new runtime configuration with every machine boot or service reload/restart". The reverse also happens. A change made with --permanent only, with no matching runtime change, is stored but, in the manual's words, "not effective immediately, only after service restart/reload or system reboot."
So the fault is one of two. A rule was added to the runtime only and later lost, or a rule was added to the permanent configuration only and has not been loaded yet.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
Rule added without --permanent |
Works until a reload or reboot, then gone | Present in firewall-cmd --list-all, absent in firewall-cmd --permanent --list-all |
Rule added with --timeout |
Rule disappears after the time given | --timeout rules are removed automatically; the manual says the option is not combinable with --permanent |
Rule added with --permanent only |
Rule not working right after the command | Present in the permanent list, absent in the runtime list |
| Rule added to a different zone | Rule exists but traffic is still blocked | firewall-cmd --get-active-zones shows the interface in another zone |
| firewalld not enabled at boot | Rules and the service are gone after a reboot | systemctl is-enabled firewalld and firewall-cmd --state |
| Invalid permanent configuration (a problem in the permanent configuration files) | The permanent list is not what you expect after a reload or start | firewall-cmd --check-config reports a problem ("XML validity and semantics") |
Prove the cause before changing anything
All of these are read-only.
1. Is firewalld running?
firewall-cmd --state
The manual says it checks whether the daemon is active and prints the state.
2. Which zone is active?
firewall-cmd --get-active-zones
firewall-cmd --get-default-zone
Active zones are those bound to an interface or source. A rule added to the default zone does nothing for an interface that is bound to another zone.
3. Compare runtime with permanent.
firewall-cmd --list-all
firewall-cmd --permanent --list-all
Add --zone=zone-name to either command to read a named zone; without it the default zone is shown. A rule in the first list and not the second is runtime only. A rule in the second and not the first is permanent but not loaded.
4. Check the permanent files.
firewall-cmd --check-config
The manual says it runs "checks on the permanent configuration" including "XML validity and semantics".
5. Is the service enabled at boot?
systemctl is-enabled firewalld
The systemctl manual describes is-enabled as checking whether the specified unit files are enabled.
Fix
Disruptive step: a reload replaces the running firewall with the permanent configuration. Any rule that exists only in the runtime is removed at that moment. The firewall-cmd manual says --reload keeps state information and that --complete-reload "will most likely terminate active connections"; it does not say whether an open SSH session survives a reload, so assume a new SSH connection would be refused if the permanent configuration lacks an SSH rule. Before you reload:
First, save the runtime state and the permanent state to dated files:
firewall-cmd --list-all > /root/firewalld-runtime-2026-11-20.txt
firewall-cmd --permanent --list-all > /root/firewalld-permanent-2026-11-20.txt
Second, copy the permanent configuration directory. The firewalld documentation says system-specific configuration lives in /etc/firewalld:
cp -a /etc/firewalld /root/etc-firewalld-2026-11-20
The cp manual describes -a as the same as -dR --preserve=all.
Third, make sure the permanent list already contains whatever keeps you connected, for example the service for SSH. If it does not, add it permanently first and compare the lists again.
Add the rule permanently
To add a port, use the form in the firewalld how-to:
firewall-cmd --permanent --zone=public --add-port=8443/tcp
Check the permanent files, then reload and read the result:
firewall-cmd --check-config
firewall-cmd --reload
firewall-cmd --list-all
The how-to says the permanent form means the port "will be open also after a system reboot or firewalld service reload". To back out of this change, run firewall-cmd --permanent --zone=public --remove-port=8443/tcp and reload again.
Save a working runtime setup as permanent
The manual provides --runtime-to-permanent, described as "Save active runtime configuration and overwrite permanent configuration with it." Disruptive step: this replaces the whole permanent configuration, including permanent rules that are not in the runtime. Only use it after you have printed both lists (steps above), compared them, and copied /etc/firewalld. Run firewall-cmd --check-config afterwards.
To back out, move the changed directory aside, put the saved copy back under its original name, and check it before loading:
mv /etc/firewalld /root/etc-firewalld-changed-2026-11-20
cp -a /root/etc-firewalld-2026-11-20 /etc/firewalld
firewall-cmd --check-config
firewall-cmd --reload
Because the changed directory is moved aside and not overwritten, files created after the first copy do not remain in /etc/firewalld; they are in /root/etc-firewalld-changed-2026-11-20 if you need them. Do not use --complete-reload: the manual says it "will most likely terminate active connections".
The rule is in a different zone from the interface
A zone is a set of rules bound to an interface or a source. If firewall-cmd --get-active-zones shows your interface in a zone other than the one you changed, traffic is judged by the other zone. Name the zone for the interface explicitly. The manual documents --get-zone-of-interface=interface for this:
firewall-cmd --get-zone-of-interface=eth0
Risk: opening a port in a zone that faces the internet exposes the service to it. Confirm which zone faces which network before adding the rule.
Then add the rule to that zone with --zone=zone-name, using the permanent add and reload form shown above (--permanent --zone=zone-name --add-port=..., then firewall-cmd --reload). To back out, run firewall-cmd --permanent --zone=zone-name --remove-port=... for the port you added and reload.
The Runtime versus Permanent page says "Changed zone bindings will be restored after the reload." That sentence is about zone bindings; a port rule added at run time only is still lost at reload, as described above.
Rules that should be temporary
Use --timeout only for rules that should expire. The manual says a timed rule "will be removed automatically afterwards".
Enable the service at boot
If systemctl is-enabled firewalld shows it is not enabled, the systemctl manual describes enable UNIT as enabling the unit, and says it "does not have the effect of also starting any of the units being enabled", so the firewall does not start now because of it. The command is systemctl enable firewalld. Disruptive step: enabling changes boot behaviour for every later restart; confirm that your permanent configuration is complete first, run firewall-cmd --check-config, and note the systemctl is-enabled firewalld output you printed above. To back out, run systemctl disable firewalld only if the noted output was disabled, which stops the firewall starting at the next boot.
Example (illustrative): web01 has an application that listens on 8443. At night an engineer runs firewall-cmd --zone=public --add-port=8443/tcp and the application works. After a kernel update and reboot, users cannot connect. firewall-cmd --list-all shows no 8443 port. firewall-cmd --permanent --list-all shows no 8443 port either, so the rule was runtime only. The engineer saves both lists and /etc/firewalld, adds --permanent --zone=public --add-port=8443/tcp, runs firewall-cmd --check-config, reloads, and the port appears in both lists.
Confirm the fix
firewall-cmd --list-allandfirewall-cmd --permanent --list-allshow the same ports and services for the zone you changed.- A connection to the port from another machine succeeds.
- After the next reload or reboot, the rule is still there.
firewall-cmd --check-configreports no problem.
What to watch afterwards
- Make every change in two steps (runtime and
--permanent), or make it runtime-first and then run--runtime-to-permanentonly after comparing lists. - Keep a dated copy of
/etc/firewalldbefore any large change. - After a reload, list the zone again. Do not assume it worked.
- If a rule seems to vanish without a reload or reboot, look at what else changes the firewall on the host, such as configuration tools or other firewall services. Compare the two lists before and after each of them runs.
Read next
Related articles you may want next.
- TroubleshootingDocker published ports ignore ufw: why it happens and how to restrict themDocker published ports bypass ufw rules. Learn why the nat table diverts traffic, how to prove it, and how to bind to 127.0.0.1 or filter in DOCKER-USER.Read article
- TroubleshootingChanged sshd_config and now SSH says "Connection refused" on port 22: prevent it and recoverSSH Connection refused after editing sshd_config? Use the console, run sshd -t, check the port, ssh.socket and bind errors. How to avoid it next time.Read article
- TroubleshootingPostgreSQL "Connection refused" on port 5432: listen_addresses, the service and the firewallPostgreSQL 'Connection refused' on port 5432? Check the service, listen_addresses (default localhost) and the port, then the network path.Read article
Risks and limits
- These commands have not been run or lab-tested.
- Rules added by other tools, such as direct nftables or iptables commands, are not covered. The firewall-cmd manual notes that changes made through the direct interface behave differently on reload when
FlushAllOnReload=no. - Page versions of the firewalld documentation are not shown, so check them against the version installed on your host.
Sources
- firewalld: Runtime versus Permanent — firewalld.org, no date shown, accessed 20 November 2026
- firewalld: Directories — firewalld.org, no date shown, accessed 20 November 2026
- firewall-cmd — firewalld.org, no date shown, accessed 20 November 2026
- firewalld: Reload firewalld — firewalld.org, no date shown, accessed 20 November 2026
- firewalld: Open a Port or Service — firewalld.org, no date shown, accessed 20 November 2026
- cp(1) — GNU coreutils 9.11 manual page, April 2026, accessed 20 November 2026
- systemctl — systemd documentation, no date shown, accessed 20 November 2026
This article was originally published on .