Web & Software Developer

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 “192.168.1.1” to your NEW IP address, and change “OLD.IP.ADDRESS” to your OLD IP address.

    UPDATE wp_options SET option_value = "http://192.168.1.1" WHERE option_value = 'http://OLD.IP.ADDRESS';
    
    
  5. Exit MySQL, then exit the terminal:

    exit
    exit 

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

By

We've 9 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.

    avatar
  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.

    THANK YOU!!

    avatar
  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!

    avatar
    • 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%';
      
      
      avatar

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:

[code]

YOUR CODE HERE 

[/code]