FIX: Local IP address changed, can’t log in to WordPress in Ubuntu LAMP

If your local IP address changes, then you may not be able to access your local WordPress admin on your local LAMP server. You can’t log in to your WordPress admin because it keeps redirecting you to the old IP address which is no longer valid.

To fix this, you need to update the “siteurl” and “home” settings in the WordPress database with your new local IP address.

You can do this in phpMyAdmin, or you can do it quicker in the terminal. Here’s how to do it in the terminal.

  1. Ctrl + Alt + T to open a terminal.
  2. Log in to MySQL:

    mysql -u root -p

    You’ll be promted to enter your MySQL password. This is the password which you set when you set up MySQL on your local machine.

  3. Access your WordPress database. Change “wordpress” to the name of your own local WordPress database. If you don’t know the name, you can get it from your wp-config.php file.
    use wordpress;
  4. Update the “siteurl” and “home” values with the new IP address. On the line below, change “” to your NEW IP address, and change “OLD.IP.ADDRESS” to your OLD IP address.
    UPDATE wp_options SET option_value = "" WHERE option_value = 'http://OLD.IP.ADDRESS';
  5. Exit MySQL, then exit the terminal:

Now, you should be able to access your local WordPress site at your new IP address.

See more:

We've 15 Responses

  1. October 23rd, 2016 at 2:56 pm

    Thanks for sharing this. I searched everywhere and other solutions were very long. This solution takes 2 minutes and it works. Very amazing. Muchas gracias.

  2. April 7th, 2017 at 8:55 pm

    My Raspberry Pi suffered through several power outages this morning and, as a result, its IP address changed. I guess it was bound to happen. Your solution was VERY useful and saved me a lot of time.


  3. June 8th, 2018 at 7:49 pm

    Thank you very much! Works like a charm! I’ve spend two days trying to fix my WP and your guide help me to fix it in secods. Thank you so much!

    • June 28th, 2018 at 10:47 am

      And I found what to put for the old value with this:L

      SELECT option_value FROM wp_options WHERE option_value LIKE 'http%';
  4. December 12th, 2020 at 4:07 pm

    Now that is the solution — I’ve had to do the same thing several times several ways before I got around to setting up a fixed ip address the right way on the router, and this was by far the quickest way of all to change the ip address in wordpress.

    Good thing I already had the fixed ip address setup before I found this method. It is so quick and simple that I would probably have put off messing with the router even longer :)!

  5. October 12th, 2021 at 12:14 pm

    Thank you for sharing this wonderful solution
    Unfortunately the localhost address did not work with my Pi so I used instead and that worked fine.
    So my querry looked like this:
    MariaDB [wordpress]> UPDATE wp_options SET option_value = “” Where option_value = ‘http://OLD.ADDRESS.IP.NUMBER’;

    If you already used the query with, you have to fill in that IP for the OLD.ADDRESS.IP.NUMBER

  6. March 2nd, 2022 at 10:42 pm

    Thank you for sharing this. This is what I ended up using, which worked well for me:

    UPDATE wp_options SET option_value = replace(option_value, 'NEW.IP.ADDRESS', 'OLD.IP.ADDRESS');

Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this: