Prevent Brute-Force WordPress Logins with WP fail2ban Updated on August 16, 2021 by InMotion Hosting Contributor 1 Minutes, 24 Seconds to Read WP fail2ban is a freemium WordPress security plugin with features for logging, brute-force attack prevention, and spam protection. In the free version you must edit the wp-config.php file with any configurations. Then, it’ll view within your WordPress dashboard. If you prefer a full-featured security plugin, we recommend Cerber Security, Antispam & Malware Scan and BBQ: Block Bad Queries. There’s a lot of data in your wp-config.php file already. However, you only need to add two lines to block user enumeration (requests for author username queries). Below we cover how to block user login attempts with WP fail2ban using your wp-config.php file (free version) and the WordPress dashboard (paid version). Install the WP fail2ban plugin before continuing. WP-config.php Log into SSH, cPanel or FTPNavigate to your WordPress root directoryEdit your wp-config.php fileUnder your database lines (e.g. define( 'DB_COLLATE', '' );, add this to block users who try to login with specific usernames:define('WP_FAIL2BAN_BLOCKED_USERS', ['^admin$', '^root$']);This blocks any user login attempts including “admin” or “root”This is case-insensitive and you can use regular expression (regex) if you’re using PHP 7 or higher.Add this to block enumeration: attempts:define('WP_FAIL2BAN_BLOCK_USER_ENUMERATION', true);Save your changes Paid Version Users with the paid subscription can block user enumeration attempts and login attempts within the WordPress dashboard: Log into your WordPress dashboardOn the left, select WP fail2ban, then SettingsClick the Users tabCheck the User Enumeration box and add Usernames to block Get more comfortable with the file with our in-depth look at wp.config.php. Enhance your WordPress performance with our NGINX-powered WordPress Hosting. Share this Article InMotion Hosting Contributor Content Writer InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals! More Articles by InMotion Hosting Related Articles How to Increase WordPress Memory Limit and Execution Time WooCommerce Setup Guide How to Create an Admin Account in WordPress via MySQL How to Add Google Analytics to WordPress Using the Jetpack Newsletter Subscription Form Benefits of Joining the WordPress Community Online How to Add Social Media Icons and Social Media Buttons to WordPress Create a Footer for WordPress How to Google Analytics to WordPress Without a Plugin Choose the Style of Your WordPress Homepage