Connect with us

WordPress Guides

[FIXED] Can’t Login to WordPress Admin After Changing URL

One of the common WordPress errors is having a problem accessing WordPress after changing the site URL on the WordPress general settings page.

The first thing you need to know is that you’re not the first or the only one to have this issue, almost all beginners will have this issue too.

In this guide, I will show you how you can fix the problem and how to change your WordPress site URL in order to be able to access your WordPress Admin again.

The reason why you cannot change the website URL again is that the page where you can change the URL again is not in the right location. As you changed the site URL, all website URLs have been updated to the new one including the URL of the General settings page where you can change the URL.

But the actual location of WordPress files is still in the old location, so when you try to visit WordPress admin URL you actually requesting a page that does not exist.

To solve the “Can’t access WordPress after changing site URL” error you simply need to change the website URL and restore the old URL.

How to Manually Change WordPress Site URL

To change the WordPress site URL you need to do it manually as you can’t do it from your WordPress admin panel. That is possible via 4 methods, the easiest two of them are:

  • Changing The WordPress site URL by editing the wp-config.php file.
  • Changing the WordPress URL via phpMyAdmin.

Fix #1: Changing the WordPress Site URL by Editing the wp-config.php file

This fix solves the problem by adding two lines of code to the WordPress configuration file ‘wp-onfig.php’.

To do so you will need to have access to your WordPress hosting panel or FTP access in order to be able to edit your wp-config.php file.

After adding the code and saving the changes to the file you will regain access to your WordPress site and you will be able to log in to the admin area as usual.

However, this method is not the best practice.

What it does is hard-coding the site URL into the code of WordPress itself. Thus, it will not be possible to change the WordPress site URL on the WP admin panel’s General settings page anymore if you are using this method.

Step 1:

Login to your WordPress hosting cPanel.

Under the Files section, click on File Manager.

Step 2:

Open File Manager and search for a file called wp-config.php and click on “Edit file”.

Step 3:

Add the following two lines of code to the top of the wp-config.php file after replacing https://www.example.com with your site URL, then save the file.

define('WP_SITEURL', 'https://www.example.com');
define('WP_HOME', 'https://www.example.com');

That’s all, try accessing your WordPress Admin panel now.

Note:
If you don’t have cPanel, you can use FTP to edit the wp-config.php file. Or you can follow the second fix to change the WordPress URL via phpMyAdmin.

Fix #2: Changing WordPress site URL via phpMyAdmin

The second method to change the WordPress URL and fix the “Can’t access WordPress after changing site URL” problem is to manually change the site URL value in the WordPress database.

This can be easily done using phpMyAdmin which most WordPress hosting providers offer for free and comes bundled with cPanel.

If your host doesn’t have phpMyAdmin you can use their alternative online database administration tool.

Moreover, if for any reason you can’t use phpMyAdmin you may use it’s lightweight, yet powerful alternative Adminer that comes in as a single PHP file.

This method is the recommended way to regain access to your WordPress site if you are not able to log in to the WordPress admin panel.

To do this follow these steps:

Be Aware!
Editing the WordPress database directly could easily break your website if not done correctly. So, if you can’t do it hire a developer.
And always make sure to take a backup of your database before editing it.

Step 1:

Login to your hosting cPanel and open phpMyAdmin.

Step 2:

Select the database of your WordPress site from the left sidebar.

Step 3:

Select “wp_options” table

Note: “wp_” prefix may differ depending on your WordPress installation settings.

Step 4:

On the right, click Edit beside either the siteurl or home entries.

Step 5:

Enter the correct values in the option_value fields, then click Go.

Step 6:

There is no step 6 🙂

Go ahead and try to access your WordPress site and log in to the WP Admin panel.

Conclusion

Now I’ve covered the two easiest methods to manually change your WordPress site URL.

They will help you regain access to your website and the WP Admin dashboard if you can’t access it after changing the WordPress site URL.

If none of the methods could help you fix the problem or just want to say hi! don’t hesitate to let us know in the comments below.

1 Comment

1 Comment

  1. Pingback: 12+ Best WordPress SEO Plugins of 2022 (Free & Paid)

Leave a Reply

Advertisement

Must See

Advertisement

More in WordPress Guides