How to set up hosts file to allow access to a remote Wordpress database from localhost

489 Views Asked by At

My team and I are working on a Wordpress site together. We have one person doing data entry on a live server and the rest of us are working locally. What we would like to do is have our local solutions point to the live server database so that we can develop around the actual database content that has been entered.

I have added our IP address as an "Access Host" to the Remote MySQL section of our hosting account and confirmed that I am able to connect to the database remotely(using the live server's IP).

Since the home/site url are pointing to our live server domain in the database, it is my understanding that we will need to edit our hosts file in order to mask our local URL as the live URL.

The local URL I use is http://localhost:8888/wordpress so I added this line to my hosts file:

127.0.0.1 ourliveserver.com www.ourliveserver.com

But when I try to access http://ourliveserver.com/wordpress I am getting ERR_CONNECTION_REFUSED

Can anyone tell me where I went wrong?

2

There are 2 best solutions below

0
J Burk On

How are your ports configured? For example on localhost you have the application running on port 8888, but when you dont specify a port the default is 80 for http.

0
user13286 On

So it turns out that you can override the home/site url directly in the wp-config.php file like this:

define( 'WP_HOME', 'http://localhost:8888/wordpress' );
define( 'WP_SITEURL', 'http://localhost:8888/wordpress' );

Everything is working correctly with those lines added.