Chef-client fails to download remote resources with test-kitchen


When using kitchen on MacOS and WindowsServer 2012 as my target test box I get errors when Chef is trying to download remote resources. It doesn’t matter if it’s an internal or external resource, they both fail.

The weird thing is that if I use the same URL that Chef is trying to use that URL works through both the browser and PowerShell via ‘iwr’ on the target VM.

Chef error:
[2017-03-07T08:02:20-08:00] ERROR: Error connecting to, retry 1/5

That URL works fine when ran with both iwr and pasting it into the address bar in a browser.

Final error from kitchen converge:
[2017-03-07T08:04:38-08:00] FATAL: Errno::ECONNRESET: windows_package[Notepad++] (notepadpp::default line 27) had an error: Errno::ECONNRESET: remote_file[C:\Users\vagrant\AppData\Local\Temp\kitchen\cache\package\npp.7.Installer.exe] (dynamically defined) had an error: Errno::ECONNRESET: Error connecting to - An existing connection was forcibly closed by the remote host.

MacOS 10.12.3
Chef DK 1.2.22

VirtualBox 5.1.8 r111374



That is odd. The primary difference is chef is going through ruby which is using its own HTTP stack and also using openssl for cert activity. I’m wondering if you have any proxy config settings in tour .kitchen.yml that might be causing chef’s http calls to go through a proxy when it really should not be. Do you mind sharing your .kitchen.yml?


name: vagrant
cpus: 2
memory: 4096

name: winrm
elevated: true

name: chef_zero
deprecations_as_errors: false

name: inspec


- name: windows-2012r2-chef-12.1


box: mwrock/Windows2012R2

  • name: windows-2012r2-ot
    box: opentable/win-2012r2-standard-amd64-nocm


  • name: default
    • recipe[ic-elasticsearch::quick]


Yeah nothing in there looks suspect. Any different result based on which vagrant box you use (mine or opentable)? Have you tried converging again after succesfully hitting those URLS in the browser? Or maybe tried on a different network? These are kind of shots in the dark but I don’t have many other ideas.


I also get a zero-length file when I try and download using just Ruby code

require 'net/http'
# Must be instead of, otherwise, it will throw exception.
Net::HTTP.start("") do |http|
    resp = http.get("/repository/7.x/7.0/npp.7.Installer.exe")
    open("c:/users/vagrant/npp.7.Installer.exe", "wb") do |file|
puts "Done."


Both your and Opentable’s vagrant boxes exhibit this behavior. I try converging multiple times after downloading either using the script above, through a browser, or through ‘iwr’ in Powershell.

Using the code above I was able to pull something from my local Artifactory repo since it’s HTTP, although the same link still fails when run from Chef.


I think the notepad++ url can be http too. Can you try having chef use an http endpoint and see if that works?


Same error:

[2017-03-07T10:35:10-08:00] ERROR: Error connecting to, retry 1/5


So after adding the following to the kitchen.yml to get a bridged connection I can download the npp public resources but I’m still stuck on downloading from our Artifactory instance:

    - ["public_network", bridge: "en4: Thunderbolt Ethernet"]

Now I’m going to test using the maven cookbook for getting resources from Artifactory.

So it looks like the NAT’ing on a Mac with Virtualbox is problematic at work, for me anyways.


I am having exact same error while running (on mac) test-kitchen with vagrant (virtualbox) on mwrock/Windows2012R2 box. remote file resource fails to load, however you can download file by directly accessing it from browser / powershell.

I am just copying Vagrantfile and logs here for reference.


name: vagrant
- [“public_network”, bridge: “en0: Wi-Fi (AirPort)”]

  name: chef_solo

  - name: mwrock/Windows2012R2
      name: winrm

  - name: default
      - recipe[ntp::default]
    attributes: {
      ntp: {
        servers: ['', '', '', ''],
        package_url: ''


-----> Starting Kitchen (v1.16.0)
-----> Converging <default-mwrock-Windows2012R2>...
       Preparing files for transfer
       Preparing dna.json
       Resolving cookbook dependencies with Berkshelf 5.6.4...
       Removing non-cookbook files before transfer
       Preparing solo.rb
-----> Chef Omnibus installation detected (install only if missing)
       Transferring files to <default-mwrock-Windows2012R2>
       Starting Chef Client, version 13.0.118
       resolving cookbooks for run list: ["ntp::default"]
       Synchronizing Cookbooks:
         - ntp (3.4.0)
       Installing Cookbook Gems:
       Compiling Cookbooks...
       Converging 7 resources
       Recipe: ntp::windows_client
         * directory[C:/NTP/etc] action create (up to date)
         * cookbook_file[C:/NTP/ntp.ini] action create (up to date)
         * remote_file[C:\Users\vagrant\AppData\Local\Temp\kitchen\cache/ntpd.exe] action create[2017-05-18T13:17:21+00:00] ERROR: Error connecting to, retry 1/5
       [2017-05-18T13:17:26+00:00] ERROR: Error connecting to, retry 2/5
       [2017-05-18T13:17:31+00:00] ERROR: Error connecting to, retry 3/5
       [2017-05-18T13:17:35+00:00] ERROR: Error connecting to, retry 4/5
       [2017-05-18T13:17:40+00:00] ERROR: Error connecting to, retry 5/5

           Error executing action `create` on resource 'remote_file[C:\Users\vagrant\AppData\Local\Temp\kitchen\cache/ntpd.exe]'

           Error connecting to - An existing connection was forcibly closed by the remote host.

           Resource Declaration:
           # In C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/ntp/recipes/windows_client.rb

            37:   remote_file "#{Chef::Config[:file_cache_path]}/ntpd.exe" do
            38:     source node['ntp']['package_url']
            39:   end

       Compiled Resource:
       # Declared in C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/ntp/recipes/windows_client.rb:37:in `from_file'

       remote_file("C:\Users\vagrant\AppData\Local\Temp\kitchen\cache/ntpd.exe") do
         provider Chef::Provider::RemoteFile
         action [:create]
         default_guard_interpreter :default
         source [""]
         use_etag true
         use_last_modified true
         declared_type :remote_file
         cookbook_name "ntp"
         recipe_name "windows_client"
         path "C:\\Users\\vagrant\\AppData\\Local\\Temp\\kitchen\\cache/ntpd.exe"
         checksum nil
         rights nil
         deny_rights nil
         verifications []

       System Info:
       ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [x64-mingw32]

       Running handlers:
       [2017-05-18T13:17:45+00:00] ERROR: Running exception handlers
       Running handlers complete
       [2017-05-18T13:17:45+00:00] ERROR: Exception handlers complete
       Chef Client failed. 0 resources updated in 28 seconds
       [2017-05-18T13:17:45+00:00] FATAL: Stacktrace dumped to C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/chef-stacktrace.out
       [2017-05-18T13:17:45+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
       [2017-05-18T13:17:45+00:00] FATAL: Errno::ECONNRESET: remote_file[C:\Users\vagrant\AppData\Local\Temp\kitchen\cache/ntpd.exe] (ntp::windows_client line 37) had an error: Errno::ECONNRESET: Error connecting to - An existing connection was forcibly closed by the remote host.
Class: Kitchen::ActionFailed
Message: 1 actions failed.
  Converge failed on instance <default-mwrock-Windows2012R2>.  Please see .kitchen/logs/default-mwrock-Windows2012R2.log for more details
Please see .kitchen/logs/kitchen.log for more details
Also try running `kitchen diagnose --all` for configuration