Originally I had mydomain.com.au, but then I let it expire as I cancelled my abn (Austalian Business Number). After that I started using mydomain.info instead to host my wordpress site. Recently I had my abn re-instated so I have mydomain.com.au back again finally.

I decided to do a permanent redirect from mydomain.com.au to mydomain.info, and I put this in /etc/apache2/sites-available/mydomain.com.au.conf file:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName mydomain.com.au
    RedirectPermanent / http://www.mydomain.info/

It looks the same in /etc/apache2/sites-enabled/mydomain.com.au.conf also.

I reloaded apache2 without error and now I get this error when I try to access www.mydomain.com.au either locally or from an external IP:

Database Error
Error establishing a database connection

I decided to test whether the redirect was working by putting a dummy html file in /var/www/mydomain.com.au. I reloaded apache2 and tried mydomain.com.au again. Still getting the database error.

So now I'm thinking it's a problem with wordpress. Does wordpress not allow you to do this kind of thing?

  • Is this the VritualHost from before? It does not look complete... what about the DocumentRoot ie. how does it know where to serve the files from? You still have a WordPress site at mydomain.com.au? Are mydomain.com.au and mydomain.info intended to be served from the same location?
    – MrWhite
    Commented Mar 20, 2015 at 8:59
  • What is an abn? If it's a typo, please correct; if it's a technical term, please explain. Commented Aug 22, 2015 at 2:01
  • ABN is Australian Business Number, it is a registration number used in Australia. It is a requirement under .com.au rules that the registrant be a legal entity or closely related somehow. Why Angie let the domain go just because she cancelled the ABN is beyond me. It isn't like they cross check.
    – Steve
    Commented Aug 22, 2015 at 2:39
  • Oh...didn't realise this was an old question...
    – Steve
    Commented Aug 22, 2015 at 2:41
  • I got it back... I think I resolved this issue but it was a while ago so I don't know how I did it... Sorry
    – Angie
    Commented Dec 24, 2016 at 2:44

1 Answer 1


A successful database connection requires at least:

  1. An active database daemon running on the server. Ask your provider here.
  2. The hostname that the database is on
  3. The port to connect to to establish a database connection. This is normally 3306 for MySQL databases with a standard configuration.
  4. A valid database name
  5. The correct username
  6. The correct password

If the domain switch also involves changing the disk that your web server is on then you will have to go back to the old server and backup the database as a large file and then reinstall it onto the new server BEFORE they decide to fully cancel the old server to the point where they reformat the hard drive. Just make sure if you do this, you set the domain name to the new domain name when you actually connect to the database.

I'm not fluent with drupal, but I'm sure theres a file in drupal that stores the database settings, and all you really have to do there after transferring everything over (including the database contents) is change the database hostname.

I think there are packages that allow you to do this easily such as PhpMyAdmin.

  • 1. I'm not switching domains. I'm redirecting one domain to another. 2. The first domain runs the wordpress install perfectly so the database connection is fine. 3. I don't use Drupal. I use Wordpress.
    – Angie
    Commented Mar 20, 2015 at 3:57
  • You should double check your database credentials for the second domain to ensure they are correct. Commented Mar 20, 2015 at 4:05
  • There is only one database connection. Ok. So I have a website that has wordpress on it, right? Then I have another one that DIRECTS TO that website. It's just a redirection. There's nothing on the second website.
    – Angie
    Commented Mar 20, 2015 at 4:12
  • @Angie does the website that has WP on it work? Is it just the redirected one that doesn't?
    – Steve
    Commented Aug 22, 2015 at 2:41

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.