Can’t login into WordPress after changing site URL.

The other day, I was forcibly logged out of WordPress after I changed the address URL in the Settings section. In my case, I had changed “http” to “https” on a fresh install.

Unfortunately, after WordPress kicked me out, it would not allow me to log back in. Furthermore, doing a password reset did not work.

The fix.

In my case, I was able to fix this issue by editing the wp-config.php file.

It is extremely important to note that this should NOT be done with a multi-site WordPress install. i.e. This fix only applies to single installs.

Before you make any changes to your wp-config.php file, you should make a manual backup of it.

Although it is unlikely that this change will cause any serious issues, it is better to be safe than sorry.

Once you have done that, you can open up your wp-config.php file and place the following two pieces of code.

//Change these URLs to match the full URL to YOUR website.
define('WP_HOME', 'https://your-website.com');
define('WP_SITEURL', 'https://your-website.com');

Make sure that you enter the full address of your website. Furthermore, you should take note of the fact that the two URLs above are using https.

If your website does not use https, then you should use http instead (without the s).

Once you have saved those changes, you will need to reload the wp-admin login page and try again. At this stage, you should be able to log back in again.

Where is the wp-config.php file?

The wp-config.php file should be in the root folder of your WordPress installation. If your entire website is WordPress, then it will be in the main public directory of the web server. However, if your WordPress is an add-on to your normal website, and it is located at a URL such as example.com/blog, then it will be in the blog directory.

Notice: Constant WP_HOME already defined.

If you see this PHP error, then it means that your site URLs have already been defined in the wp-config.php file.

In other words, they may have already been added to the file.

As a result, you will need to remove the code that you just copied and pasted and do a “CTRL + F” for WP_HOME.

Once you find the WP_HOME and WP_SITEURL constants, you can change them to match the correct address of your website.