Trying to post WordPress comments redirects to 127.0.0.1

Whenever I try to post a comment on on of my WordPress articles it is redirecting to 127.0.0.1. I’ve never worked on this site on my local server, so I’m not sure why it would be going there.

Commenting used to work fine. Any ideas on how to fix this?

Related posts

Leave a Reply

3 comments

  1. Had this problem today, the plugin that caused it was All in One WP Security– plugin.

    If I disabled “Block SpamBot Comments”-feature, everything works again.
    (You can find this checkbox under WP Security / Spam Prevention, in your WordPress dashboard (panel on the left side).

    This is probably caused by having WordPress installed on a website with add-on domain (2 domain names point to the same site), there weren’t any issues with single domain WordPress site and having that spam block feature enabled.

  2. Check your .htaccess file for a rewrite rule that specifies 127.0.0.1 that may have been added by a plugin.

    For example, if you use the AIOWPS plugin on a multisite installation and have enabled the “Block Spambots from Posting Comments” feature, a rewrite rule is added to .htaccess that redirects comment posts to 127.0.0.1 if the referer does not match the primary domain.

    #AIOWPS_BLOCK_SPAMBOTS_START
    <IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_METHOD} POST
    RewriteCond %{REQUEST_URI} ^(.*)?wp-comments-post.php(.*)$
    RewriteCond %{HTTP_REFERER} !^http(s)?://primary.example.com [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} ^$
    RewriteRule .* http://127.0.0.1 [L]
    </IfModule>
    #AIOWPS_BLOCK_SPAMBOTS_END
    

    You can disable this feature and add a cutom rule that preserves its functionality by checking to see if the REFERER header contains the same domain name as the HOST header.

    #BLOCK_SPAMBOTS_START
    <IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_METHOD} POST
    RewriteCond %{REQUEST_URI} ^(.*)?wp-comments-post.php(.*)$
    RewriteCond %{HTTP_HOST}@@%{HTTP_REFERER} !^([^@]*)@@https?://1/.* [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} ^$
    RewriteRule .* http://127.0.0.1 [L]
    </IfModule>
    #BLOCK_SPAMBOTS_END
    

    see: http://tltech.com/info/referrer-htaccess/

  3. Please deactivate all the plugins. If this solves your problem try to find out which plugin is making the problem. If this does not, then the problem is with .htaccess. For this delete the .htaccess file in the WordPress root directory and create a new .htaccess file following the below steps.

    1. Go to Dashboard > Settings > Permalinks
    2. Select a suitable permalink structure and click Save.
    3. WordPress will generate a new .htaccess file code, copy the code.
    4. Create a file named .htaccess in the WordPress root directory and paste the code into it and save.