{"id":5307,"date":"2008-12-29T17:48:15","date_gmt":"2008-12-29T12:18:15","guid":{"rendered":"https:\/\/www.quickonlinetips.com\/archives\/?p=5307"},"modified":"2026-10-13T13:36:44","modified_gmt":"2026-10-13T08:06:44","slug":"ban-ip-to-stop-wordpress-comment-spam-forever","status":"publish","type":"post","link":"https:\/\/www.quickonlinetips.com\/archives\/2008\/12\/ban-ip-to-stop-wordpress-comment-spam-forever\/","title":{"rendered":"How to Ban IP Addresses to Stop WordPress Comment Spam (2026)"},"content":{"rendered":"<p>Can you ban IP addresses to stop WordPress comment spam? Yes, and when a few IPs keep hammering your comment form, an IP ban stops them before they ever reach your spam folder. In 2008 we used the WP-Ban plugin and our spam comments dropped to almost zero. Spammers now rotate through thousands of IPs, so IP bans work best alongside a good spam filter. Here are the ways to ban an IP in WordPress in 2026, from the built-in settings to your firewall.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-large wp-image-63770\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/ban-ip-wordpress-comment-spam-1024x538.webp\" alt=\"Ban IP addresses to stop WordPress comment spam\" width=\"760\" height=\"399\" srcset=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/ban-ip-wordpress-comment-spam-1024x538.webp 1024w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/ban-ip-wordpress-comment-spam-300x158.webp 300w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/ban-ip-wordpress-comment-spam-150x79.webp 150w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/ban-ip-wordpress-comment-spam-768x403.webp 768w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/ban-ip-wordpress-comment-spam.webp 1200w\" sizes=\"(max-width: 760px) 100vw, 760px\" \/><\/p>\n<p><strong>Quick answer:<\/strong> To ban an IP address in WordPress, copy the spammer&#8217;s IP from <strong>Comments<\/strong>, then add it to <strong>Settings &gt; Discussion &gt; Disallowed Comment Keys<\/strong> to send their comments straight to trash. To block the IP from your whole site, use a plugin such as WP-Ban or your security plugin, or block it in Cloudflare or <code>.htaccess<\/code>. Keep Akismet or another spam filter running, because most spam comes from changing IPs.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_89 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6ae7c34f689e4\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #1a202c;color:#1a202c\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #1a202c;color:#1a202c\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6ae7c34f689e4\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2008\/12\/ban-ip-to-stop-wordpress-comment-spam-forever\/#How_to_find_a_spammers_IP_address\" >How to find a spammer&#8217;s IP address<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2008\/12\/ban-ip-to-stop-wordpress-comment-spam-forever\/#Method_1_Disallowed_Comment_Keys_built_into_WordPress\" >Method 1: Disallowed Comment Keys (built into WordPress)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2008\/12\/ban-ip-to-stop-wordpress-comment-spam-forever\/#Method_2_Ban_IPs_with_a_plugin\" >Method 2: Ban IPs with a plugin<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2008\/12\/ban-ip-to-stop-wordpress-comment-spam-forever\/#Method_3_Block_IPs_in_Cloudflare\" >Method 3: Block IPs in Cloudflare<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2008\/12\/ban-ip-to-stop-wordpress-comment-spam-forever\/#Method_4_Block_IPs_in_htaccess\" >Method 4: Block IPs in .htaccess<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2008\/12\/ban-ip-to-stop-wordpress-comment-spam-forever\/#Be_careful_when_you_ban_IPs\" >Be careful when you ban IPs<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2008\/12\/ban-ip-to-stop-wordpress-comment-spam-forever\/#Better_long-term_protection_against_comment_spam\" >Better long-term protection against comment spam<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2008\/12\/ban-ip-to-stop-wordpress-comment-spam-forever\/#Frequently_asked_questions\" >Frequently asked questions<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2008\/12\/ban-ip-to-stop-wordpress-comment-spam-forever\/#Does_banning_IPs_stop_all_comment_spam\" >Does banning IPs stop all comment spam?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2008\/12\/ban-ip-to-stop-wordpress-comment-spam-forever\/#What_replaced_the_WordPress_Comment_Blacklist\" >What replaced the WordPress Comment Blacklist?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2008\/12\/ban-ip-to-stop-wordpress-comment-spam-forever\/#Can_a_banned_person_still_read_my_blog\" >Can a banned person still read my blog?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2008\/12\/ban-ip-to-stop-wordpress-comment-spam-forever\/#How_do_I_unban_an_IP\" >How do I unban an IP?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"How_to_find_a_spammers_IP_address\"><\/span>How to find a spammer&#8217;s IP address<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In <strong>Comments<\/strong>, each comment shows the author&#8217;s IP address under their email. Click the IP to see all comments from that address. If dozens of spam comments share one IP or a narrow range, it&#8217;s worth banning.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Method_1_Disallowed_Comment_Keys_built_into_WordPress\"><\/span>Method 1: Disallowed Comment Keys (built into WordPress)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Go to <strong>Settings &gt; Discussion<\/strong> and paste IPs, one per line, into <strong>Disallowed Comment Keys<\/strong> (called Comment Blacklist before WordPress 5.5). Any comment from those IPs goes straight to the trash. On the same screen:<\/p>\n<ul>\n<li>Set <strong>Comment Moderation<\/strong> to hold comments with 1 or more links. Most spam includes links.<\/li>\n<li>Turn on <strong>Comment author must have a previously approved comment<\/strong>.<\/li>\n<li>Close comments on older posts automatically after 30 to 90 days if old posts attract most spam.<\/li>\n<\/ul>\n<p>This blocks comments but not visits, which is usually what you want.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Method_2_Ban_IPs_with_a_plugin\"><\/span>Method 2: Ban IPs with a plugin<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><a href=\"https:\/\/wordpress.org\/plugins\/wp-ban\/\" target=\"_blank\" rel=\"noopener\">WP-Ban<\/a>, the plugin we used in 2008, is still maintained. It bans users by IP, IP range, host name, user agent or referrer, shows them a custom message, and keeps stats on blocked attempts. Security plugins such as Wordfence also let you block IPs, IP ranges and whole countries from their firewall settings.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Method_3_Block_IPs_in_Cloudflare\"><\/span>Method 3: Block IPs in Cloudflare<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>If your site uses Cloudflare, go to <strong>Security &gt; WAF &gt; Tools<\/strong> (IP Access Rules) and block the IP or range. Blocked visitors never reach your server, which also saves resources.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Method_4_Block_IPs_in_htaccess\"><\/span>Method 4: Block IPs in .htaccess<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>On Apache or LiteSpeed servers, you can add rules to the <code>.htaccess<\/code> file in your site root:<\/p>\n<pre><code>&lt;RequireAll&gt;\r\n  Require all granted\r\n  Require not ip 203.0.113.45\r\n  Require not ip 198.51.100.0\/24\r\n&lt;\/RequireAll&gt;<\/code><\/pre>\n<p>Back up <code>.htaccess<\/code> first, because a typo can take your site offline. Nginx servers use <code>deny<\/code> rules in the server config instead.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Be_careful_when_you_ban_IPs\"><\/span>Be careful when you ban IPs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Never block your own IP<\/strong> or your office&#8217;s network.<\/li>\n<li><strong>Avoid huge ranges:<\/strong> many readers share IPs through mobile networks, so wide bans can block real visitors and even search engine bots.<\/li>\n<li><strong>Review bans regularly:<\/strong> spammers move on, and old banned IPs may be reassigned to real users.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Better_long-term_protection_against_comment_spam\"><\/span>Better long-term protection against comment spam<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>IP bans are a quick fix. For lasting protection, combine them with a spam filter. <a href=\"https:\/\/akismet.com\/\" target=\"_blank\" rel=\"noopener\">Akismet<\/a> has blocked <a href=\"https:\/\/www.quickonlinetips.com\/archives\/2008\/07\/akismet-blocks-million-spam-comments\/\">millions of spam comments<\/a> on our site over the years. See our list of the <a href=\"https:\/\/www.quickonlinetips.com\/archives\/2014\/09\/4-best-wordpress-plugins-to-stop-comment-spam\/\">best WordPress plugins to stop comment spam<\/a>, and how to <a href=\"https:\/\/www.quickonlinetips.com\/archives\/2012\/11\/stop-akismet-auto-delete-spam-comments\/\">stop Akismet auto-deleting comments<\/a> so you can rescue real ones.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Frequently_asked_questions\"><\/span>Frequently asked questions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"Does_banning_IPs_stop_all_comment_spam\"><\/span>Does banning IPs stop all comment spam?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>No. Most spam bots use many IPs. Bans stop repeat offenders; filters like Akismet catch the rest.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"What_replaced_the_WordPress_Comment_Blacklist\"><\/span>What replaced the WordPress Comment Blacklist?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Since WordPress 5.5 it&#8217;s called Disallowed Comment Keys, under Settings &gt; Discussion.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Can_a_banned_person_still_read_my_blog\"><\/span>Can a banned person still read my blog?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>With Disallowed Comment Keys, yes; only their comments are blocked. With WP-Ban, Cloudflare or .htaccess, they can&#8217;t load the site.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"How_do_I_unban_an_IP\"><\/span>How do I unban an IP?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Remove it from the list where you added it and save the settings.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Can you ban IP addresses to stop WordPress comment spam? Yes, and when a few IPs keep hammering your comment&#8230;<\/p>\n","protected":false},"author":4,"featured_media":63770,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"default","_kad_post_title":"default","_kad_post_layout":"default","_kad_post_sidebar_id":"","_kad_post_content_style":"default","_kad_post_vertical_padding":"default","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[6,7],"tags":[49,17],"class_list":["post-5307","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogging","category-security","tag-tutorials","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/5307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/comments?post=5307"}],"version-history":[{"count":3,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/5307\/revisions"}],"predecessor-version":[{"id":65283,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/5307\/revisions\/65283"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media\/63770"}],"wp:attachment":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media?parent=5307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/categories?post=5307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/tags?post=5307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}