IP Addresses in WordPress

Since I was just working in a test instance of GCP, I didn’t have DNS running for the server and was using IP addresses for everything.  This posed a problem with WordPress since it stored the IP addresses from the original installation server in the configuration.  Naturally when I booted the new instance group using the disk image created from the original WordPress server, GCP assigned a new IP address to the server and the site no longer worked.

The fix is to update the database to reflect the new public IP address via ssh.  After some searching in the WordPress blogs, I was able to find the following changes which seem to have done the trick. If you don’t do this step, then whenever you access the site it will attempt to access the old IP address and fail.

chris@instance-group-wordpress-lmfd:$ sudo mysql -u root -p
password:##########
mysql> use wordpress;
mysql> show tables;
+-----------------------+
| Tables_in_wordpress |
+-----------------------+
| wp_commentmeta |
| wp_comments |
| wp_links |
| wp_options |
| wp_postmeta |
| wp_posts |
| wp_term_relationships |
| wp_term_taxonomy |
| wp_termmeta |
| wp_terms |
| wp_usermeta |
| wp_users |
+-----------------------+
mysql> UPDATE wp_options SET option_value = "http://NEW_IP_ADDRESS"
WHERE option_value = 'http://OLD_IP_ADDRESS';
mysql> exit;

I originally did this with IPv4 addresses.  However, since my goal was to get the site running with IPv6, I first changed the addresses to IPv6 via the console to test if a raw IP address would work, then I changed both addresses to the domain name, which would be the preferred option when working with a production site.  In both cases WordPress accepted the changes and the site worked as expected.  Below is a screenshot of the console with a mix of IPv6 and domain name configured.

WordPress Console

Comments are closed.