Vagrant: OSX Sierra + Trusty64 experiencing connection reset by peer errors

Created on 30 Oct 2016  ·  13Comments  ·  Source: hashicorp/vagrant

Vagrant version

Currently 1.8.6.

Host operating system

Mac Os X Sierra 10.12.

Guest operating system

Ubuntu (Trusty64)

Other versions

php 5.5.9

Vagrantfile

Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/trusty64"

  config.vm.network "forwarded_port", guest: 80, host: 8080
  config.vm.network "forwarded_port", guest: 3306, host: 33306

  config.vm.network "private_network", type: "dhcp"
  config.vm.network "public_network"

  config.vm.provider "virtualbox" do |vb|
    vb.memory = "1024"
    vb.name = "coderdojo-website"
  end

  config.vm.synced_folder ".", "/vagrant", type: "nfs", :nfs => { :mount_options => ["dmode=777","fmode=777"] }

  config.vm.provision "shell", inline: <<-SHELL
    apt-get update

    echo mysql-server-5.5 mysql-server/root_password password supersafe | debconf-set-selections
    echo mysql-server-5.5 mysql-server/root_password_again password supersafe | debconf-set-selections

    apt-get install -y mysql-common mysql-server mysql-client git

    apt-get install -y apache2

    apt-get install -y php5 libapache2-mod-php5
    apt-get install -y php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-sqlite php5-tidy php5-xmlrpc php5-xsl

    /etc/init.d/apache2 restart

    rm -rf /var/www/html
    ln -fs /vagrant/web /var/www/html

    apt-get install -y g++
    curl -sL https://deb.nodesource.com/setup_0.12 | sh
    apt-get install -y nodejs

    npm install -g less

    curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

    cd /vagrant

    composer install

    php bin/console doctrine:database:create
    php bin/console doctrine:schema:update --force
    yes | php bin/console doctrine:fixtures:load
    php bin/console assets:install --symlink
    php bin/console cache:clear
  SHELL
end

Debug output

screenshot 2016-10-30 14 04 33

Expected behavior

Php should be able to do requests to https hosts.

Actual behavior

It gives the php error Connection reset by peer. Whenever using file_get_content or stream_get_contents this happens. However, not all hosts produce this. For example:

  • file_get_contents("https://coderdojo.nl") -> ✅
  • file_get_contents("https://google.com") -> ❎

To make things even weirder, when retrieving google.com, I do get half of the body and thén the error is triggered.

I have also found it only happens on the CLI version of php and not within apache. I compared the two php.ini files but did not find any major differences besides memory limits and timeout settings.

References

After extensively searching the internet and trying / confirming various things my last resort is checking in with Vagrant because it could very well be a bug of vagrant 1.8.6 in combination with Sierra. So far, I've found only 1 other person who could reproduce this and he was on the same stack as me. Others do not experience this issue.

Please note, this is happening in all my vagrant boxes (all running trusty 64) ever since i've installed vagrant 1.8.6 on a new macbook running sierra.

Here is a list of things I've tried and confirmed:

  • StackOverflow

    • Checked if https is available in stream wrappers for php

    • Checked if allow_fopen_urls is enabled

    • Checked if allow_url_include is enabled

    • Checked valid ssl certificate for host (we are talking Google here!)

  • StackOverflow

    • Tried disabling verification of peer in context settings

  • Github Public Repo Issue

    • Checked openssl version in trusty64 -> OpenSSL 1.0.1f 6 Jan 2014

  • StackOverflow

    • Checked iptables on guest -> non-existend

  • Firewall is NOT activated on my host machine

Final words

I really hope there are more people with this is and will come forward with this because it is very very frustrating that I am not able to work on my projects in vagrant at the moment, this is forcing me to install everything locally with a local dev stack which is simply.... FRUSTRATING.

If anyone needs more information for debugging purposes please don't hesitate to ask. I won't destroy the box so I can easily grab logs and config files you might need.

bug providevirtualbox upstream

Most helpful comment

Seems to be a bug of VirtualBox, downgrading to version 5.1.6 r110634 works for me. See also this thread https://forums.virtualbox.org/viewtopic.php?f=1&t=80310

All 13 comments

I have the same problem running;

  • macOS 10.12.1
  • Vagrant 1.8.6
  • VirtualBox 5.0.28 r111378

I'm using the same box as @ChristianVermeulen, facing the same problem. I haven't encountered this error on my Homestead box however.

I have the same problem running;
macOS 10.12.1
Vagrant 1.8.6
VirtualBox 5.1.8 r111374

I'm using a different box.

Ditto.
macOS 10.12.1
Vagrant 1.8.5
VirtualBox 5.0.28 r111378

Seems to be a bug of VirtualBox, downgrading to version 5.1.6 r110634 works for me. See also this thread https://forums.virtualbox.org/viewtopic.php?f=1&t=80310

Eventually I only downgraded Vagrant to 1.8.6 and that worked out... So i'm not too sure it is just a virtual box issue.

@ChristianVermeulen Your initial report said you were on 1.8.6 when the problem started. Am I misreading that?

The virtualbox forum link posted here https://github.com/mitchellh/vagrant/issues/7946#issuecomment-257800546 does seem to suggest that this is an upstream issue.

Just spent the last several hours debugging this issue and I have it narrowed it down to a VirtualBox regression. My Node app inside a Vagrant VirtualBox VM reaching back to 10.0.2.2 to talk to another app was getting its connection reset half way about 30% of the time (Node's HTTP end event fired before receiving full response — end was being fired after reading 2634 bytes off a 5000+ bytes content-length response). I wish I had found this post and the associated forum link earlier!

Posting the resolution that worked for me, in case someone else is still struggling with this:

  1. Downgrade to VirtualBox to 5.0.26
  2. No need to downgrade Vagrant. My version is 1.8.7 (latest as of today).
  3. Rebuild VMs.

Although this issue set my targets back by several hours already, I still hope to find some time to try upgrading VirtualBox version one at a time (binary search and faster?) to find out exactly which version broke and to further narrow it down to the actual patch that broke it. In case someone has the time, that's what I'd suggest as the next step (given there is not a conclusive root cause yet on the forum thread, that I could find).

Ditto.
OSX 10.11.6
VirtualBox 5.1.8
Vagrant 1.8.7

Was able to resolve by downgrading to VirtualBox 5.0.26.

Also encountered this issue.

Running:
OSX 10.12.1 (and 10.11.6)
VirtualBox 5.1.8
Vagrant 1.8.6 (and encounted on 1.8.7)

SOLVED WITH:
Downgraded Virtualbox from 5.1.8 to 5.1.6.

VirtualBox 5.1.10 seems to be doing better than 5.1.8

Closing this as upstream issue. Cheers!

https://forums.virtualbox.org/viewtopic.php?f=1&t=80310

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings