Connection to Site on Vagrant Box Refused

I have setup bedrock and bedrock ansible. Tree structure:

├── bedrock-ansible
│   ├── group_vars
│   ├── hosts
│   ├── roles
│   │   ├── common
│   │   ├── composer
│   │   ├── deploy
│   │   ├── fail2ban
│   │   ├── ferm
│   │   ├── github-ssh-keys
│   │   ├── hhvm
│   │   ├── mariadb
│   │   ├── memcached
│   │   ├── nginx
│   │   ├── php
│   │   ├── rollback
│   │   ├── sshd
│   │   ├── ssmtp
│   │   ├── sudoers
│   │   ├── users
│   │   ├── wordpress-install
│   │   ├── wordpress-setup
│   │   └── wp-cli
│   ├── vars
│   └── vendor
│       └── roles
├── bedrock-capistrano
│   └── config
│       └── deploy
└── site
    ├── config
    │   └── deploy
    ├── scripts
    │   └── Roots
    ├── vendor
    │   ├── composer
    │   ├── johnpbloch
    │   └── vlucas
    └── web
        ├── app
        └── wp

41 directories

Just getting started with ansible. Vagrant file is

mysql_root_password: devpw

web_user: vagrant

wordpress_sites:
  sage.dev:
    site_hosts:
      - sage.dev
    local_path: '../site' # path targeting local Bedrock project directory (relative to Ansible root)
    repo: git@github.com:roots/bedrock.git
    site_install: true
    site_title: WP Remote
    admin_user: username
    admin_password: password
    admin_email: admin@example.dev
    system_cron: true
    multisite:
      enabled: false
      subdomains: false
    env:
      wp_home: http://sage.dev
      wp_siteurl: http://sage.dev/wp
      wp_env: development
      db_name: sage
      db_user: user
      db_password: 

php_error_reporting: 'E_ALL'
php_display_errors: 'On'
php_display_startup_errors: 'On'
php_track_errors: 'On'
php_mysqlnd_collect_memory_statistics: 'On'
php_opcache_enable: 0

xdebug_install: false
php_xdebug_remote_enable: true
php_xdebug_remote_connect_back: true
php_xdebug_remote_host: localhost
php_xdebug_remote_port: 9000
php_xdebug_remote_log: /tmp/xdebug.log
php_xdebug_idekey: XDEBUG
php_max_nesting_level: 200

I did a vagrant up and the box runs well. Here reload example:

vagrant reload
==> default: Checking if box 'roots/bedrock' is up to date...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Checking for host entries
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Exporting NFS shared folders...
==> default: Preparing to edit /etc/exports. Administrator privileges will be required...
Password:
==> default: Mounting NFS shared folders...
==> default: Mounting shared folders...
    default: /vagrant => /Users/jasper/webdesign/sage/bedrock-ansible
==> default: Creating bind mounts for selected devices
==> default: Creating bind mount from /vagrant-nfs-sage.dev to /srv/www/sage.dev/current
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: to force provisioning. Provisioners marked to run always will still run.

and I can ping it at the designated ip address

ping sage.dev
PING sage.dev (192.168.50.5): 56 data bytes
64 bytes from 192.168.50.5: icmp_seq=0 ttl=64 time=0.638 ms
64 bytes from 192.168.50.5: icmp_seq=1 ttl=64 time=0.418 ms
^C
--- sage.dev ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.418/0.528/0.638/0.110 ms

. I can ssh into the box using vagrant ssh as well.The hosts file has also been adjusted by the vagrant plugin:

192.168.50.5  sage.dev  # VAGRANT: key (default) / key

What I cannot do now however is load the site going to site.dev. Connection seems to be refused:

This webpage is not available
ERR_CONNECTION_REFUSED

What do I need to do to load the site on the vagrant box from my guest OSX system?

1 Like

Well I did a vagrant destroy and vagrant up and now I do get a page loading. Just see errors now:

Warning: require_once(/srv/www/sage.dev/current/config/application.php): failed to open stream: No such file or directory in /srv/www/sage.dev/current/web/wp-config.php on line 8

Fatal error: require_once(): Failed opening required '/srv/www/sage.dev/current/config/application.php' (include_path='.:/usr/share/php:/usr/share/pear') in /srv/www/sage.dev/current/web/wp-config.php on line 8

Added the missing wp-config.php and application.php. No idea why they were not added by Bedrock before. But I got further. Just now I experienced a database connection error. I adjusted the root password - user I was using for the database connection and destroyed the vagrant box and re-created it again and now all is up and running.

Something is wrong if those files are missing. You should never have to manually create them.

Going by your dir structure (thanks for that!) in your first post your config directory is missing the environments/ folder. I suggest re-downloading/cloning/copying Bedrock’s source to make sure it’s complete.

Thanks @swalkinshaw Will do.

I’m having a similar problem with the latest versions of bedrock-ansible and bedrock. Did a fresh install according to instructions on the example site.

My dir structure if you’re curious:

.
├── ansible
│   ├── group_vars
│   ├── hosts
│   ├── roles
│   │   ├── common
│   │   ├── composer
│   │   ├── deploy
│   │   ├── fail2ban
│   │   ├── ferm
│   │   ├── github-ssh-keys
│   │   ├── hhvm
│   │   ├── mariadb
│   │   ├── memcached
│   │   ├── nginx
│   │   ├── php
│   │   ├── rollback
│   │   ├── sshd
│   │   ├── ssmtp
│   │   ├── sudoers
│   │   ├── users
│   │   ├── wordpress-install
│   │   ├── wordpress-setup
│   │   └── wp-cli
│   ├── vars
│   └── vendor
│       └── roles
└── site
    ├── config
    │   └── environments
    ├── scripts
    │   └── Roots
    ├── vendor
    │   ├── composer
    │   ├── johnpbloch
    │   └── vlucas
    └── web
        ├── app
        └── wp

38 directories

ping and traceroute both show that the server is running, and I can vagrant ssh into it:

PING clp.dev (192.168.50.10): 56 data bytes
64 bytes from 192.168.50.10: icmp_seq=0 ttl=64 time=0.389 ms
64 bytes from 192.168.50.10: icmp_seq=1 ttl=64 time=0.270 ms
64 bytes from 192.168.50.10: icmp_seq=2 ttl=64 time=0.282 ms
64 bytes from 192.168.50.10: icmp_seq=3 ttl=64 time=0.222 ms
^C
--- clp.dev ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.222/0.291/0.389/0.061 ms

traceroute to clp.dev (192.168.50.10), 64 hops max, 52 byte packets
 1  clp.dev (192.168.50.10)  0.445 ms  0.223 ms  0.262 ms

I’ve re-provisioned, destroyed, and re-upped the box several times with varying settings, to no avail.

Here’s my ansible/group_vars/development:

mysql_root_password: devpw

web_user: vagrant

wordpress_sites:
  clp.dev:
    site_hosts:
      - clp.dev
    local_path: '../site' # path targeting local Bedrock site directory (relative to Ansible root)
    repo: bb:bigsweater/clp.git
    site_install: true
    site_title: Ceci Liz Photography
    admin_user: admin
    admin_password: admin
    admin_email: admin@example.dev
    multisite:
      enabled: false
      subdomains: false
    ssl:
      enabled: false
    system_cron: true
    env:
      wp_home: http://clp.dev
      wp_siteurl: http://clp.dev/wp
      wp_env: development
      db_name: example_dev
      db_user: example_dbuser
      db_password: example_dbpassword

php_error_reporting: 'E_ALL'
php_display_errors: 'On'
php_display_startup_errors: 'On'
php_track_errors: 'On'
php_mysqlnd_collect_memory_statistics: 'On'
php_opcache_enable: 0

xdebug_install: false
php_xdebug_remote_enable: true
php_xdebug_remote_connect_back: true
php_xdebug_remote_host: localhost
php_xdebug_remote_port: 9000
php_xdebug_remote_log: /tmp/xdebug.log
php_xdebug_idekey: XDEBUG
php_max_nesting_level: 200

I’ve used Bedrock for awhile now, but this is my first time using it since Sage 8 was released. Been awhile since my last fresh install…never had the connection_refused problem before, that I can recall.

EDIT: I should also note that I can use wp-cli inside the VM.

$wp core version --extra
WordPress version: 4.2.2
Database revision: 31535
TinyMCE version:   4.109 (4109-20150505)

Same thing happening for me. I have used Bedrock/Ansible/Sage quite extensively maybe on the last 10 projects without a hitch. I recently started a new project today, using all the latest versions of each… Following the example project directions exactly, still having issues getting dev environment up. Google chrome gives the following:
This webpage is not available

ERR_CONNECTION_REFUSED
Hide details
Google Chrome’s connection attempt to example.dev was rejected. The website may be down, or your network may not be properly configured.

Curling the domain gives me this:
curl: (7) Failed to connect to example.dev port 80: Connection refused

I double checked the nginx config, everything looked fine there. I destroyed the project and attempted to piece it together twice more, still no avail.

Something is definitely broken with the latest version of Bedrock-Ansible. I used a version I downloaded maybe 2 weeks ago in place of the cloned one I used today, and it is working as intended.

edit: So i did some investigating as to how far back the error might have been introduced, it seems it was a commit yesterday to some nginx configs. I reverted the following changes back to their original and I was able to get a successful VM working.

This is the commit that is suspect: https://github.com/roots/bedrock-ansible/commit/41dc1c0e4af4354db14f3fbc88732627c6840083

@bigsweater and @nathan_roca thanks for reporting. Going to close this thread on here so the latest issue is an actual bug and not related to the problem in the thread to begin with.

You can follow it here: https://github.com/roots/bedrock-ansible/issues/225