Skip to content
Skip to main content
Free .com domain on yearly Starter and up 30-day money-back guarantee Free website migration Live chat with real people, 7 days a week
Hostking
  • Pricing
  • Hosting
    Web hostingNVMe hosting for any website, from $2.50/mo WordPress hostingInstalled, cached and backed up for you Reseller hostingHost your own clients under your brand Free migrationWe move your website from another host
  • Websites
    AI website builderSee your website in about a minute, free Website CareWe build it and look after it, from $19.99/mo Recent designsWebsites we built for customers
  • Domains
    Register a domain.com, .net and more, from $22/year Transfer a domainBring the domain you already have
  • Email
  • Help
Chat with us
USD

Choose your country

South AfricaZARUAEAEDUKGBPNigeriaNGNKenyaKESIndiaINRGlobalUSDCanadaCADEuropeEURMalaysiaUSDPhilippinesPHP
Web hostingWordPress hostingAI website builderWebsite CareDomainsEmailPricingHelpLog in
Server Administration

Using fail2ban to block WordPress login attacks

  • Hostking Team

  • 2015-07-09

fail2ban logo 1
#image_title
Share on Social Media
xfacebook

Today and in the past few days I’ve been often flooded with POST requests that look like this:

103.19.180.119 - - [09/Jul/2015:10:50:02 +0200] "POST /wp-login.php HTTP/1.1" 403 1139
103.19.180.119 - - [09/Jul/2015:10:50:03 +0200] "POST /wp-login.php HTTP/1.1" 403 1139
103.19.180.119 - - [09/Jul/2015:10:50:04 +0200] "POST /wp-login.php HTTP/1.1" 403 1139
103.19.180.119 - - [09/Jul/2015:10:50:04 +0200] "POST /wp-login.php HTTP/1.1" 403 1139
103.19.180.119 - - [09/Jul/2015:10:50:05 +0200] "POST /wp-login.php HTTP/1.1" 403 1139
103.19.180.119 - - [09/Jul/2015:10:50:06 +0200] "POST /wp-login.php HTTP/1.1" 403 1139

To stop these attacks we found we had to install fail2ban with CSF.

The way to perform this is to install fail2ban first using:

rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum install fail2ban

Once installed go to:

/etc/fail2ban

Then edit the jail.local file

add the following:

[wp-auth]
enabled = true
filter = wp-auth
action = csf-ip-deny[name=wordpress port="http,https"]
logpath = /etc/httpd/logs/access_log
bantime = 300
maxretry = 3

Once done

Go to /etc/fail2ban/action.d

create a file called csf-ip-deny.conf

and add the following within it:

# CSF / fail2ban integration
[Definition]
actionstart =
actionstop =
actioncheck =
actionban = csf -d <ip> Added by Fail2Ban for <name>
actionunban = csf -dr <ip>

[Init]

name = default

After that go to /etc/fail2ban/filter.d and create a file called wp-auth.conf

add the following within it:

# WordPress brute force auth filter: /etc/fail2ban/filter.d/wp-auth.conf:
#
# Block IPs trying to auth wp wordpress
#
# Matches e.g.
# 134.255.143.49 - - [24/Jun/2015:13:43:31 +0200] "POST /wp-login.php HTTP/1.1" 200 2930
#
[Definition]
failregex = ^<HOST> .* "POST .*wp-login.php HTTP/1.1 403"
ignoreregex =
actionban = csf -d <ip> Added by Fail2Ban for <name>
actionunban = csf -dr <ip>

Once done restart fail2ban

service fail2ban restart

And now you should find it being blocked within CSF Deny list. :)




Follow us on Social Media
xfacebookinstagram

Hosting set up for WordPress

NVMe SSD, free SSL, daily backups and a team that fixes WordPress problems with you. Free migration from any host.

See WordPress HostingOr let us build and look after your site ›

Keep Reading

image 18Server AdministrationSecuring a Cpanel Web Serverimage 17Server AdministrationCloudLinux and CageFSimage 15Server AdministrationWhat is AlmaLinux? The Best Enterprise-Grade Linux Distro
bruteforcefail2banwp-login
Website Care

Need a website for your business?

We build it, a designer finishes it, and we look after it. Hosting, domain and email included.

$19.99/month · cancel any time

See My Website FreeWhat's included ›

Topics

  • Blogging (7)
  • Business Tips (19)
  • Domains & DNS (16)
  • Email (11)
  • Hostking News (4)
  • Online Shops (15)
  • Security (28)
  • SEO & Marketing (15)
  • Web Hosting (25)
  • Website Design (10)
  • WordPress (60)

Latest Guides

  • Isometric illustration of a laptop login screen with a padlock and a database icon representing WordPress password recovery
    Can’t Login to WordPress? Recover Admin Access Without a Plugin2026-10-23
  • Illustration of an email envelope with a padlock representing email login authentication errors
    Fix “Unable to Verify Account Name or Password” Email Errors2026-10-19
  • Isometric illustration of a laptop, notebook and checklist representing writing blog posts with AI assistance
    How to Write Blog Posts Faster Using AI Without Losing Your Voice2026-10-16
  • Person troubleshooting a website issue on a laptop screen
    Why Is My Website Down? How to Check and What to Do2026-10-16
  • Illustration of a blog dashboard or website editor on a computer screen
    Joomla vs WordPress for a Small Business Blog: Which Fits You?2026-10-16

Just need hosting?

  • NVMe SSD and free SSL
  • Daily backups
  • Free migration from any host
  • 30-day money-back guarantee

From $5/month

See Hosting PlansWordPress hosting ›

Stuck on something?

Our support team is on live chat every day, 05:00 to 20:00 UTC. Ask us before you buy, too.

Chat with usBrowse the Help Centre ›
Hostking

Hosting, websites, domains and email for small businesses, since 2013.

4.3/5 on Trustpilot
HostingWeb hostingWordPress hostingReseller hostingcPanel reseller hosting
WebsitesAI website builderWebsite CareRecent designs
Domains & EmailRegister a domainTransfer a domainBusiness email
CompanyAbout usContact usGuidesBlog
Our regions:South AfricaUAEUKNigeriaKenyaIndiaCanadaEuropeMalaysiaPhilippines
© 2013–2026 Hostking. Prices in US dollars.TermsPrivacyAcceptable use
imunify-bot-check
Share on Social Media
xfacebook
Follow us on Social Media
xfacebookinstagram