If your WordPress host IP changed accidently and and you can not login into WordPress, there are several ways to update the site URL without logging in. Then your site will be working properly. If your site does not, check your
.htacess file in which you may have settled some redirect rules with the old IP, replace all the old IP with the new IP.
Change the site URL
Changing the site URL provides several ways to change the site URL and this article gives two more ways, choose one you like and then try to refresh your site a couple of times, your site will be OK.
Change URL in database through phpmyadmin
Even your WordPress site does not load, you can access the phpmyadmin tool.
wp_options table, update two records whose
home. Make the records are listed ascendingly by
option_id, you can easy find these two records.
Change URL in database through terminal
Open a terminal, connect
mysql -u root -p or
/path/to/your/mysql -u root -p if your
mysql is not in the path. Here it suppose your
mysql user is
root. It will prompt you input the password. If you forget, check them in your
use to select the database you want to change. You can also find the database name in your
wp-config.php file. Then you can update the options whose
home like below.
# Connect mysql $ /myfolder/mysql/bin/mysql -u root -p Enter password: ******** Welcome to the MariaDB monitor. Commands end with ; or g. Your MariaDB connection id is 2 Server version: 10.1.31-MariaDB mariadb.org binary distribution ... # Choose database MariaDB [(none)]> use my-database-name Database changed MariaDB [training]> # You can check the old values for the option whose option_name in ('siteurl', 'home') MariaDB [training]> select * from wp_options where option_name in ('siteurl', 'h ome') -> ; +-----------+-------------+----------------------+----------+ | option_id | option_name | option_value | autoload | +-----------+-------------+----------------------+----------+ | 2 | home | http://xxx.xxx.x.xxx | yes | | 1 | siteurl | http://xxx.xxx.x.xxx | yes | +-----------+-------------+----------------------+----------+ 2 rows in set (0.12 sec) # Update the values with the new IP MariaDB [training]> update wp_options set option_value="http://192.168.1.100" wh ere option_name in ('siteurl', 'home') -> ; Query OK, 2 rows affected (0.09 sec) Rows matched: 2 Changed: 2 Warnings: 0 MariaDB [training]> exit Bye
functions.php of your currently used theme, add these two temporary lines to the file, immediately after the initial
update_option( 'siteurl', 'http://192.168.1.100' ); update_option( 'home', 'http://192.168.1.100' );
Use your own IP instead of
Load the admin page a couple of times, the site should come back up. Then remove them after the site is up and running again.
Add these two lines to your
wp-config.php, where “example.com” is the correct location of your site.
define( 'WP_HOME', 'http://example.com' ); define( 'WP_SITEURL', 'http://example.com' );
Note it’s just hard-coding the values into the site itself. You won’t be able to edit them on the General settings page anymore when using this method.
Change old IP in your
.htaccess file if any
If your site does not come back, check your
.htaccess (probably the top-level
.htaccess) file and replace all the old IP with the new one if any.