With Wordpress, is it possible to work on localhost but have the DB on a server? So that workflow will be:

1) Work on localhost (but connected to remote database)

2) Upload JUST files via backup software daily

This would eliminate the pain of uploading the database each time (logging into cPanel, dropping DB, uploading DB, running SQL find&replace command, logging into site and updating permalinks...)

I know how to connect to the actual remote database with wp-config.php, but it results in a 404 page because (I'm guessing) it has the wrong site URL in the DB?


My httpd-vhosts.conf:

<VirtualHost *:80>
  ServerAdmin [email protected]
  DocumentRoot "c:/wamp/www"
  ServerName localhost
  ServerAlias localhost.com www.localhost.com
  ErrorLog "logs/locahost-error.log"
  CustomLog "logs/localhost-access.log" common
<Directory "c:/wamp/www">
    AllowOverride All
        Require local

<VirtualHost *:80>
  ServerAdmin [email protected]
  DocumentRoot "c:/wamp/www/site"
  ServerName site.localhost
  ServerAlias www.site.local
  ErrorLog "logs/site.local-error.log"
  CustomLog "logs/site.local-access.log" common
<Directory "c:/wamp/www/site">
    AllowOverride All
        Require local

My hosts:   localhost   site.local

1 Answer 1


Yes, the 404 is because the local and remote server URLs are different. As a solution:

  • You should set the local domain to be the same as the remote server
  • In wp-config.php connect to the remote DB
  • When you will need to access the remote server you'll need to update the file hosts and comment out the line with your remote url
    • If your hosts file is updated on start/stop of your local server you can just stop the server and you'll have acces to the remote

If your domain name is xdirtseries.co.za you should set in vhost the server name and alias to match the domain, so that when you local server is started you'll see the local version, otherwise your online version.

ServerName xdirtseries.co.za
ServerAlias www.xdirtseries.co.za

And the hosts file: xdirtseries.co.za www.xdirtseries.co.za

This should work :)

  • Thanks for your reply:) Just a few quick questions: 1) where do I set the local domain to remote server, 2) the hosts file - are you referring to the OS host file?
    – Guit4eva
    Commented May 29, 2015 at 9:01
  • 1
    @Guit4eva, What is your OS ? If Windows: C:\Windows\System32\drivers\etc\hosts, if Linux or Mac /etc/hosts. For 1: you should use virtual hosts. httpd.apache.org/docs/2.2/vhosts Commented May 29, 2015 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.