Getting Started With the WordPress Theme Developer Handbook
What the WordPress Theme Developer Handbook Covers The WordPress Theme Developer Handbook is the official documentation for anyone learning how WordPress themes…
When you update or redesign a WordPress site, maintenance mode shows visitors a temporary notice while you work. Fail2Ban does a different job. It reads your server logs for repeated failures and tells the server to block the IP address behind them. Your theme can style the maintenance page, but it can't give Fail2Ban access to server logs or control your firewall.
Handle these two tasks separately. First, pick a maintenance method that sends the right HTTP response and turns off cleanly when you're done. Then set up Fail2Ban on a host where you have access to the logs and firewall. Before you start, ask your hosting provider if they let you install and manage Fail2Ban. If they don't, you'll need to use their built-in security tools or ask about rate limiting at their network edge.
WordPress turns on its own maintenance mode whenever it updates core files. During an update, WordPress creates a .maintenance file in the WordPress root and deletes it once the update finishes. WordPress checks that file's timestamp and treats it as expired after ten minutes. Because WordPress built this mechanism for quick updates, it won't hold a planned maintenance window open indefinitely.
For planned work outside of an update, install a maintained plugin or build a custom feature. Plugins behave differently from one another, so check the compatibility details and test the output before you rely on one. For instance, the Maintenance plugin directory page describes one specific plugin, and its features and compatibility notes don't apply to other maintenance plugins.
You can also use a block theme to display a branded maintenance page, though a developer has to wire it up first. A WordPress Developer Blog tutorial shows how to add a code hook that looks for a template with the maintenance slug. Once the developer adds that hook, an editor can design the page under Appearance → Editor → Templates. In that tutorial's setup, logged-in users bypass the maintenance page, though other plugins and custom setups may handle logged-in users differently. If you want background on how block themes structure templates and styles, see block theme development concepts.
A good custom maintenance page tells visitors what is happening and, when appropriate, how to reach you for help. Under the hood, your server should return a temporary-unavailable status instead of a normal success response. WordPress core's default maintenance response sends an HTTP 503 status with a Retry-After header set to 600 seconds. A custom drop-in, theme hook, or plugin can override those defaults. The block-theme tutorial, for example, sets its own 503 status, retry guidance, and no-cache headers. Check the exact status code and headers your setup sends, and make sure any CDN or proxy stops serving the cached maintenance page once you reopen the site.
Fail2Ban watches your server logs, matches entries against rules, and bans an IP address when it crosses a threshold you set. A Fail2Ban jail ties four things together: the log source, a filter that spots the events, the retry limits, and the action that applies the ban. Fail2Ban doesn't activate a jail automatically when you write its configuration file. The jail options reference lists defaults like five retries within ten minutes, but those defaults aren't safe for every site.
Fail2Ban's maintainers warn you not to edit jail.conf directly, because package updates can overwrite your changes. Put your local settings in jail.local or in a file inside jail.d/, as shown in the upstream configuration. Before you turn on a jail, find out where your host writes the events you want to catch. Depending on your server, they might live in a system log, a web-server access log, or a systemd journal.
The Fail2Ban WordPress guide covers two ways to catch WordPress security events. You can install the WP fail2ban plugin, which sends events to syslog (a standard system log) and ships with filters for failed logins and XML-RPC authentication attempts. Or you can write a filter that reads your web-server access logs directly. That second approach takes more care. The guide's example treats a POST to /wp-login.php with a 200 status as a failed login, while a successful login redirects with a 302 status. Those status codes match the behavior in that guide, but they aren't universal across every WordPress setup. Check your own logs to see how your site responds before you put that filter into production.
If you decide to filter access logs, make sure your web server records the visitor's IP address in a format your filter can parse. NGINX lets you choose where logs go and which fields they include, such as the client address, the request, and the status code; see its logging configuration. If a CDN or reverse proxy sits in front of your server, verify which IP address shows up in the log before you enable bans. If the log records the proxy's address instead of the visitor's, Fail2Ban will block traffic coming through the proxy.
Base your retry and ban thresholds on the attacks you want to stop and the people who use your site. A strict threshold blocks repeated attacks quickly, but it can also catch legitimate visitors. People in the same office often share one IP address, and mobile users switch IP addresses frequently. Editors, uptime monitors, and single sign-on providers can also generate bursts of requests from a single source. The WordPress Fail2Ban guide suggests different thresholds for its "hard" and "soft" filters, but treat those numbers as examples to test against your own traffic. Start with a cautious threshold, review the events your filter matches, and confirm the behavior before you let it ban addresses on a live site.
Keep your filter focused on the specific endpoints you want to protect, such as /wp-login.php or /xmlrpc.php. WordPress flags XML-RPC as a frequent target. If you don't use XML-RPC, WordPress recommends turning it off. If you rely on it for Jetpack or a mobile app, restrict access and limit how often clients can connect. Write down any exceptions you make and test those connections after you change a rule. Likewise, if you put Basic Authentication across all of /wp-admin/, you can break features like admin-ajax.php, so check what your site depends on before locking down the whole directory.
Remember that Fail2Ban only reacts to repeated events that show up in your logs. It can't patch vulnerable themes or plugins, replace regular updates, or stop every kind of attack. Pair it with unique long passwords and a password manager. WordPress core doesn't include two-factor authentication, so you'll need a plugin or an identity provider to add it. WordPress also points out that if WordPress throttles logins itself, PHP still has to handle the traffic during a heavy attack, so server-level or network-edge controls help keep the load down.
If WordPress stays stuck on its core maintenance message, first make sure the update has stopped running. Then look for a leftover .maintenance file in your WordPress root directory. WordPress's update instructions tell you to delete that file if an update fails or gets interrupted, though you should never remove it while WordPress is still actively updating.
A failed update can also leave behind a core_updater.lock option in the database, which stops WordPress from starting another update. The WordPress Hosting Team notes that this lock expires on its own after 15 minutes. If the update has already ended and the lock is still blocking you, the team's upgrade guidance recommends running wp option delete core_updater.lock. Once the site is back up, check your pages and server logs before you try the update again.
Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.
Take a look at vroni.com