keepcalculator

06 Numbers and Powers

Fix 500 Error After Changing WordPress URL

Card No. 06·23821 · Updated · Standard formula, shown below

When you change the WordPress Site Address or Home URL and immediately get a 500 Internal Server Error, the site usually breaks because WordPress can no longer find its own files or because a cached setting is pointing to the old location. This guide walks you through the most reliable fixes, from editing the database directly to clearing server caches, so you can get your site back online without losing content.

What You’ll Need

  • Access to your hosting control panel (cPanel, Plesk, or your host’s custom panel).
  • FTP or File Manager access to your site’s files.
  • phpMyAdmin or another database management tool (usually available in cPanel).
  • Your database name, username, and password (found in your wp-config.php file).

Step-by-Step

  1. Confirm the error is server-side. Open your site in a browser and check the exact message. If it says “500 Internal Server Error” with no other details, it’s a server-level issue, not a plugin or theme conflict. If you see a WordPress error page, skip to step 6.
  2. Backup your database and files. Before making any changes, create a full backup. In cPanel, use the “Backup” tool or a plugin like UpdraftPlus. If you can’t access the dashboard, use phpMyAdmin to export the database and FTP to download all files.
  3. Edit the URL in the database via phpMyAdmin. Log into phpMyAdmin, select your WordPress database, and click the SQL tab. Run this query, replacing example.com with your actual domain (no http://):
    UPDATE wp_options SET option_value = 'http://example.com' WHERE option_name = 'siteurl' OR option_name = 'home';
    If your table prefix isn’t wp_, adjust it (e.g., mywp_options). This directly sets the correct URLs.
  4. Clear any server-side caches. If your host uses a caching layer (like Varnish, LiteSpeed Cache, or a CDN), purge it. In cPanel, look for “Cache Manager” or “CloudFlare” and clear all caches. Also delete the cache folder inside wp-content if it exists (it’s safe to remove).
  5. Check for syntax errors in .htaccess. Open the .htaccess file in your site’s root via FTP or File Manager. If it’s empty or has extra lines, replace it with the standard WordPress block:
    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # END WordPress

    Save and test.
  6. Disable plugins and switch to a default theme. If the error persists, a plugin or theme might be causing it. Rename the plugins folder to plugins_old via FTP. Then rename the themes folder to themes_old. This forces WordPress to use no plugins and a default theme. If the site loads, rename the folders back and then rename individual plugins one by one to find the culprit.
  7. Increase PHP memory limit. Sometimes a low memory limit triggers a 500 error. Add this line to your wp-config.php file, just before the “That’s all, stop editing” comment:
    define('WP_MEMORY_LIMIT', '256M');
  8. Check file permissions. Incorrect permissions can cause 500 errors. Via FTP, set all directories to 755 and all files to 644. Do not change wp-config.php permissions; keep it at 644 or 600.
  9. Verify the database connection. If your wp-config.php has the wrong database host (some hosts use localhost, others use a specific hostname), the site will fail. Double-check the values with your host’s documentation.
  10. Contact your hosting provider. If none of the above works, the issue might be on the server side (e.g., PHP version incompatibility, mod_rewrite not enabled). Provide them with the exact error message and what you’ve tried.

Common Mistakes

  • Forgetting to include the protocol (http:// or https://) when updating the URL in the database.
  • Using the wrong table prefix in the SQL query – always check your wp-config.php for $table_prefix.
  • Editing the URL in the wrong database – if you have multiple WordPress installs, you might update the wrong one.
  • Not clearing caches after the database change – the old URL may still be cached, causing a redirect loop.
  • Changing the URL in the General Settings page without having a backup – if the site breaks, you can’t get back in to revert.

Tips

  • Always use the full URL with the protocol (http:// or https://) when setting the site URL.
  • If you’re moving from HTTP to HTTPS, make sure your SSL certificate is installed and active before changing the URL.
  • Test the site after each step – you don’t need to complete all steps to see if the issue is resolved.
  • Keep a local copy of your wp-config.php and .htaccess files so you can restore them if needed.
  • Consider using a staging site to test URL changes before applying them to production.

Troubleshooting

If the 500 error persists after following all steps, try these additional checks:

  • Check the PHP error log. In cPanel, look for the “Errors” or “Error Log” section. The error message will tell you exactly which file is causing the issue. Common errors include a missing function, a syntax error in a theme file, or a memory exhaustion.
  • Rename the wp-content folder temporarily. If the site loads with a blank page, the issue is in your uploads or other content. Rename it to wp-content_old and create a fresh wp-content folder with the default plugins, themes, and uploads folders. This is a last resort because it will break your media library, but it can isolate the problem.
  • Check for a corrupted .htaccess file – even after replacing it, if the error persists, the file might have been re-created with bad rules. Delete it entirely and try again – WordPress will regenerate it.
  • Verify the PHP version. If your host recently changed the PHP version, your theme or plugins might not be compatible. Try switching to a default theme via FTP (rename the current theme folder) and disabling all plugins to see if the error goes away.
  • Check for a firewall or security plugin. If you have a security plugin like Wordfence, it might block access after a URL change. Rename the plugin folder to disable it temporarily.

Frequently Asked Questions

Why does changing the WordPress URL cause a 500 error?

The most common cause is that WordPress stores the URL in the database, and when you change it, the server can’t find the site’s files or the database connection fails. This often happens when the URL is changed incorrectly (e.g., missing protocol) or when there’s a caching layer serving the old URL.

Can I fix it without phpMyAdmin?

Yes, you can use FTP to edit the wp-config.php file and add two lines to override the URL: define('WP_HOME','http://example.com'); and define('WP_SITEURL','http://example.com');. This is a temporary fix that works until you can update the database properly.

Will I lose my content if I edit the database?

No, editing the wp_options table only changes the site URL fields. Your posts, pages, and media remain untouched. Always backup before doing so, though.

What if the error only happens on the front end but not the admin?

This usually indicates a theme or plugin issue. Try switching to a default theme and disabling all plugins. If the front end loads, re-enable them one by one to find the culprit.

How do I know if it’s a server issue vs. a WordPress issue?

If you see a plain white page with “500 Internal Server Error” and no WordPress branding, it’s likely a server-level issue. If you see a WordPress error message like “Error establishing a database connection,” it’s a WordPress configuration problem.

Can I use a plugin to fix this?

If you can access the admin dashboard, you can use a plugin like “Better Search Replace” to update URLs in the database. But if the 500 error prevents access, you’ll need to use phpMyAdmin or FTP.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →