Changing siteurl in the database not working

WordPress has a number of standard methods to change or override these url options:

  • using update_option() function in functions.php or anywhere else in the code, this way:
    update_option( 'siteurl', 'https://yourdomain.com' );

    update_option( 'home', 'https://yourdomain.com' );
    This is most likely your case because update_option() edits db entries at runtime.

    In this case, just remove or comment out these lines where you find them.
  • using define();
    define( 'WP_HOME', 'https://yourdomain.com' );
    define( 'WP_SITEURL', 'https://yourdomain.com' );
    This only overrides the setting but does not change the entries in the database.

If your url changes in the address bar, but does not change in the database, this may happen due to WordPress caching. Try one of these:

  • edit wp-config.php and add define(‘ENABLE_CACHE’, FALSE);
  • add a query string with an argument to clear cache, i.e. https://yourdomain.com/?x=z
  • if you use CloudFlare or other caching service, clear cache for this url