Skip to content
I can't log in

Locked out after changing the site address

Someone changed the address under Settings, and now WordPress points to an address that doesn't work. How to set it back in wp-config.php.

You need
FTP
Updated

Settings → General holds two addresses: "WordPress Address (URL)" and "Site Address (URL)". They're stored in the database as siteurl and home, and WordPress builds every link and redirect from them, including the login. If one of them is wrong, WordPress redirects you to an address that doesn't respond, and you can't get into wp-admin to fix it.

The cause can be a typo, https on a server without a certificate, or a new domain that doesn't point to the server yet. You get back in by overriding the addresses in wp-config.php or by fixing them directly in the database.

Override the address in wp-config.php

  1. Connect with FTP or the file manager in your hosting panel, and open the root folder where wp-config.php is.
  2. Download a copy of the file before you change it.
  3. Add these two lines above the line /* That's all, stop editing! Happy publishing. */:
define( 'WP_HOME', 'https://example.com' );
define( 'WP_SITEURL', 'https://example.com' );
  1. Replace https://example.com with the address the site had before the change. Keep http:// or https:// as it was, and leave out the trailing slash.
  2. Upload the file and log in at /wp-login.php.

WP_HOME is the site address and WP_SITEURL is the WordPress address. They're the same unless WordPress is installed in a subfolder. In that case WP_SITEURL includes the folder, for example https://example.com/wp.

While the lines are in wp-config.php

The constants override the values in the database, and the fields under Settings → General are greyed out. You can leave the lines in place. If you would rather manage the address in the settings again, fix it in the database first and then remove the lines.

Fix the address in the database

  1. Open phpMyAdmin in your hosting panel and select the WordPress database.
  2. Open the wp_options table. If the site uses a prefix other than wp_, you find it as $table_prefix in wp-config.php.
  3. Find the rows where option_name is siteurl and home, and enter the correct address in option_value. siteurl is the WordPress address and home is the site address.
  4. Remove the two lines from wp-config.php and check that you can still log in.

With SSH and WP-CLI, two commands do the same:

wp option update home 'https://example.com'
wp option update siteurl 'https://example.com'

If you meant to change the address

The new address has to respond before you switch, whether it's a new domain or a move to https:

  • The domain must point to the server in DNS.
  • The domain must be added to the hosting account, with an SSL certificate if the address uses https.

Once the new address responds, switch as described above. Posts, pages and images still have the old address stored in the database, including in serialised data. A plain search and replace in SQL corrupts serialised data, so use wp search-replace in WP-CLI or the Better Search Replace plugin. Back up the database first, and do a dry run with --dry-run before you change anything.

Finally, set up a 301 redirect from the old address to the new one, so existing links and search engines find the site.

When you're stuck

If you still can't log in with the right address in wp-config.php, check that the domain points to the right server with Google Admin Toolbox Dig, and that the certificate is valid with SSL Labs. The DNS records are at your domain registrar or in Cloudflare, and the certificate is in the hosting panel. If the login page just reloads, you have a redirect loop. If you don't have FTP access, whoever runs the site can fix the address for you.