WordPress Login Redirect Loop – How to Fix

I recently ran into a redirect loop issue while attempting to log into WordPress recently that drove me crazy. And all the internet searching I could do led me no where…

How to fix WordPress login loop issues
Not being able to access your WordPress admin is frustrating. If you ever experience a redirect loop while trying to log in, try this fix to correct the issue.

 

The Problem

I attempt to login to a WordPress install, enter my credentials, and click the Log In button. Something we are all familiar with, right? But what do I see? The page refreshed and I get the exact same page. I must have typed something in wrong, right? So I try again. And I see the same page again… Am I going insane? Wait, the login box didn’t do the cute shake that WordPress does when your credentials are incorrect. So now what…

The Solution

I cut right to the chase. For me, the solution to this WordPress Login loop problem was in the database. I know for some of you this is scary territory, but it’s not too bad as long as you don’t go on a clicking frenzy. And sadly, if you can’t log in there’s really no other way to fix this issue. So step one is to login to the database. I just used PhpMyAdmin for this. If you don’t have access to this, get a hold of your web-hosting company or if you have a web-developer on hand have them do this for you. Once logged, find your WordPress table, and navigate to the wp_options table. NOTE: It’s possible this table has a different prefix, so it could be named xxxoptions where xxx is the name of your site or something like that. There are two fields in this table that could be the culprit to your WordPress Login page looping problem.

  1. option_id: 1, option_name: siteurl
  2. option_id: 36, option_name: home

The issue I ran into here was that the option_value for the siteurl was not set correctly – it was set to the non-www version of the site, but the site ONLY responds to the www version of our URL. So it was something with this setting interacting to how the webserver is configured that created a redirect loop that was preventing me from logging into the site. So to fix this, ensure that the URL given in both of these two fields is set to what you expect it to be. Change the value and you should be all set to go.

The Why

Why you might ask have you run into this issue?  In my case the root cause was the moving of hosting providers that operated on a different webserver.  For that reason, the configuration was slightly different and thus caused the issue.

If that wasn’t your reason, yet the root cause is still to blame, I’d assume that this value got changed one way or another.  It is possible to change these values while in the WordPress Admin (as long as you are logged in and can stay logged in of course), so it could be a user made a change for the worse here.

The other worst case scenario is it’s always possible a hacker got into your site and changed valued in your database.  I don’t like shouting doom and gloom though, and in my mind this is a very very  minor chance, but it is a possibility.