Error establishing a database connection & How to access Vagrant

Been using roots for awhile but not in its bedrock + ansible variant.
I’ve installed via git the bedrock-ansible directory and the bedrock theme and renamed it to the default for testing purpouses.
I run under Windows, so I’ve used the suggested vagrant file for windows, as well as the file.
After installing everything I’ve run composer install. The vagrant box goes up without any errors.
My problems are:

  • I’ve no idea how to access the VM. I have used Laravel’s homestead. And for that after ssh vagrant@ -p 2222, I introduce my passphrase and I’m in. For bedrock in my local dev server I’ve used admin, root, as well as my passphrase. All to no avail.

  • The second problem that I have, is that when I hit the url I get the following errors:

    Warning: mysqli_real_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /srv/www/ on line 1379
     Warning: mysqli_real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known in /srv/www/ on line 1379
    Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /srv/www/ on line 1409
    Warning: mysql_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /srv/www/ on line 1409
    Warning: mysql_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /srv/www/ on line 1409

    ###Error establishing a database connection
    This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at database_host. This could mean your host’s database server is down

    How do I access the db from outside the Vagrant? With Laravel-Homestead I can access port 33060 and I’m in. Is there an equivalent in this case?

Clearly, I’m doing something ( many things :blush: ) wrong. How do I go about solving this mess that I’ve gotten myself into?

Thanks in advance,


Hi Mauro!

SSH to VM. Have you tried the command vagrant ssh to access the VM? The output of vagrant ssh-config reveals that the ssh user is vagrant and connects using an “insecure private key” (no passphrase needed; depending on your ssh config settings).

mysql errors. Did the ansible log show any errors in the DB-related provisioning (e.g., from your initial vagrant up)?

Connect to DB. I use an ssh connection (vagrant user mentioned above, with its insecure private key) and connect to the DB (port 3306, I think) with the db_user and db-password specified in group_vars/development. Might not work till you’ve resolved the mysql issues.


Thanks a lot @fullyint. Sorry I didn’t see the reply before, but for some reason I didn’t get the preceptive email with your reply…

Ok, so after restarting the VM I finally got in. There where a couple of things going on here. I tried getting in the VM with the flags and it always asked me for a password. Consequently, it would block my ip address and thus block me out. The second thing was that I was trying to login to or vagrant but with a user. This meant that the VM always prompted me for a password.

As for the DB I finally got it sorted out. It was a stupid mistake on my part. All I had to do was copy the credentials from \bedrock-ansible\group_vars to \ As I was trying to change the least amouth of things possible I tried to stick with as many default settings as I could. I copied from \bedrock-ansible\group_vars to \\.env:

  • db_name: example_dev => DB_NAME=example_dev
  • db_user: example_dbuser => DB_USER=example_dbuser
  • db_password: example_dbpassword => DB_PASSWORD=example_dbpassword
  • DB_HOST=localhost

I also changed - and this is something that maybe @swalkinshaw could update - the following:

  • WP_HOME= => WP_HOME=
    This little gotcha didn’t take me too long, but it surprised me at first that the site would redir to - which is an actual site and it works :wink:

After I get my bearings I will try to post a step by step micro tutorial on how to setup the whole thing. It’s all there in the documentation but it’s a bit overwhelming as there are so many technologies and workflows to take in.

Having said that, I know I wouldn’t even give it a go if the guys at hadn’t done all the heavy lifting for us and many thanks for the community you have been able to foster.

Many thanks and happy holidays

Good job figuring it out!

Looks like you, I, and others don’t receive email notifications from discourse :confused:.

You shouldn’t need to edit the .env file, unless things are different on windows. Bedrock-ansible automatically creates the .env file for you, based on values in group_vars/development. (See the task named “Create .env file of sites” in roles/wordpress-sites/tasks/main.yml.)

Just to double-check a few things:

  • Did you use the original Vagrantfile at the link you posted, or the updated version @swalkinshaw posted to the comments? Also, you might consider how the more recent Vagrantfile updates (PR 101) might affect the windows version.
  • You mentioned restarting the VM, but have you tested whether starting from scratch would resolve any issues? Backup up your DB first, if it has anything to keep. Then vagrant destroy the vm and do a completely fresh vagrant up.
  • Sounds like you’ve used the default DB passwords. If ever you change them, you may need to edit your Vagrantfile to use = 'ubuntu/trusty64' instead of = 'roots/bedrock' (more info).

@fullyint Regarding the .env file, you are right. I think I modified it before doing the composer create-project.
As for the Vagranfile from @swalkinshaw, and, if I remember correctly, I did try it. But I did once I had used the “old” vagrant + to get the machine running. Unfortunately, it didn’t work for me. I’ll give it another go once I have a bit more time.

As for the VM (Virtual Machine), I didn’t have any issues other than my inability to access it, so I didn’t fiddle more with it.

Thanks for the heads up regarding the passwords. I’m sure that I’ll run into more :smile: problems once I try to deploy the test website. My initial try will be with Digital Ocean, so I might give a go to your config file.

Thanks again for all your help