Support » Fixing WordPress » Error establishing a database connection on second virtual host

  • Resolved benjaone1



    I have created a 2nd virtual host on a LAMP stack Ubuntu 16.04 and exsratcted WordPress on the document root.

    I get Error establishing a database connection.
    WP provides a new wp-config.php it couldn’t connect with it.
    I am using the same database- name and user as from my first virtual host.

    How do I get WP to connect to the same database using the same wp-config.php?


    • This topic was modified 2 years, 2 months ago by benjaone1.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • “Error establishing a database connection” means that there is a problem with the connection to your database
    This is a problem with the credentials stored in the wp-config.php file not matching what mysql expects.
    Try reviewing the following codex article for some guidance:

    Additionally there are a few steps/questions to help with troubleshooting:

    1. Can you confirm that you have a running MySQL instance on the Host server?

    2. Do you have any other active WordPress sites currently working in the same server?

    3. Can you confirm that your MySQL username and password match what you have in config.sys?

    4. Is this database (and its tables) accessible using PhpMyAdmin, or similar?

    6. Are you able to connect to a brand new, fresh database on your Host Server?

    You may have tried all the above, but it will be useful to confirm first that you have tried them all

    Best Regards.

    Hi Mateus,

    Thanks so much for your help !!!

    I had the second site up and running

    Then I changed the site url from WordPress Dashboard to since this is the url I want. And now I can’t access the site.

    I had similar issues on my first virtual host and learned to redirect from wp-config.php and phpmyadmin.

    Problem is those tricks doesn’t work on second virtual host.

    This is my second virtual host:

    <VirtualHost *:80>
    DocumentRoot /var/www/html/
    <VirtualHost *:80>

    How do I get to direct to my site, thank you very much!

    Moderator Steve Stern


    Support Team Volunteer

    ServerName is wrong


    Get rid of the second VirtualHost definition

    Thank you very much!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Error establishing a database connection on second virtual host’ is closed to new replies.