{"record":{"id":"133e9b36f79e4ac2","repo":"hashicorp/vagrant","slug":"nfs-requires-a-host-only-network-to-be-created-pl-133e9b","errorCode":null,"errorMessage":"NFS requires a host-only network to be created.\nPlease add a host-only network to the machine (with either DHCP or a\nstatic IP) for NFS to work.","messagePattern":"NFS requires a host-only network to be created\\.\nPlease add a host-only network to the machine \\(with either DHCP or a\nstatic IP\\) for NFS to work\\.","errorType":"exception","errorClass":"Vagrant::Errors::NFSNoHostonlyNetwork","httpStatus":null,"severity":"error","filePath":"plugins/providers/virtualbox/action/prepare_nfs_settings.rb","lineNumber":83,"sourceCode":"\n          if host_ip && !machine_ip.empty?\n            interface = @machine.provider.driver.read_host_only_interfaces.detect do |iface|\n              iface[:ip] == host_ip\n            end\n            host_ipaddr = IPAddr.new(\"#{host_ip}/#{interface.fetch(:netmask, \"0.0.0.0\")}\")\n\n            case machine_ip\n            when String\n              machine_ip = nil if !host_ipaddr.include?(machine_ip)\n            when Array\n              machine_ip.delete_if do |m_ip|\n                !host_ipaddr.include?(m_ip)\n              end\n              machine_ip = nil if machine_ip.empty?\n            end\n          end\n\n          raise Vagrant::Errors::NFSNoHostonlyNetwork if !host_ip || !machine_ip\n\n          env[:nfs_host_ip]    = host_ip\n          env[:nfs_machine_ip] = machine_ip\n        end\n\n        # Finds first host only network adapter and returns its adapter number\n        # and IP address\n        #\n        # @return [Integer, String] adapter number, ip address of found host-only adapter\n        def find_host_only_adapter\n          @machine.provider.driver.read_network_interfaces.each do |adapter, opts|\n            if opts[:type] == :hostonly\n              @machine.provider.driver.read_host_only_interfaces.each do |interface|\n                if interface[:name] == opts[:hostonly]\n                  return adapter, interface[:ip]\n                end\n              end\n            end","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/providers/virtualbox/action/prepare_nfs_settings.rb#L65-L101","documentation":"Before writing NFS exports, the action locates the host's host-only adapter IP (host_ip) and the machine's IPs, then keeps only machine IPs that fall inside the host adapter's network. If either side ends up nil it raises NFSNoHostonlyNetwork: NFS mounting between host and guest needs both endpoints on a host-only network.","triggerScenarios":"`vagrant up` with an NFS-typed synced folder (`config.vm.synced_folder '.', '/vagrant', type: 'nfs'`) while the VM has no host-only adapter, or its private-network IP sits outside the host adapter's subnet (e.g. host-only adapter on the host renumbered after upgrades).","commonSituations":"Adding nfs folders to a Vagrantfile that never defined a private_network; host-only adapter IP changed by VirtualBox or another tool so host_ipaddr.include?(machine_ip) fails; DHCP private networks where the guest got an address on a different range; switching from VirtualBox provider (hostonly) to another provider semantics.","solutions":["Add a private network: `config.vm.network 'private_network', ip: '192.168.56.10'` (static is most reliable for NFS)","Check the host side matches: `VBoxManage list hostonlyifs` shows the adapter IP; the guest IP must be in that subnet (fix adapter ipconfig or the Vagrantfile ip)","If you do not need NFS, drop `type: 'nfs'` and use the default rsync/virtualbox folder type","Re-create the host-only network (delete + recreate in Host Network Manager) if its IP drifted, then `vagrant reload`"],"exampleFix":"# Vagrantfile - before:\nconfig.vm.synced_folder '.', '/vagrant', type: 'nfs'   # no private network defined\n\n# after:\nconfig.vm.network 'private_network', ip: '192.168.56.10'\nconfig.vm.synced_folder '.', '/vagrant', type: 'nfs'","handlingStrategy":"validation","validationCode":"# before enabling nfs synced folders, ensure a host-only network exists\nhas_private = vagrantfile_networks.any? { |n| n[:ip] || n[:type].to_s == 'dhcp' && n[:virtualbox__intnet].nil? }\nusing_nfs = vagrantfile_synced_folders.any? { |_, o| o[:type].to_s == 'nfs' }\nabort 'NFS needs a private_network - add config.vm.network' if using_nfs && !has_private","typeGuard":null,"tryCatchPattern":"begin\n  env.cli('up')\nrescue Vagrant::Errors::NFSNoHostonlyNetwork\n  warn 'Add config.vm.network :private_network with a static ip, or drop type: \"nfs\"'\nend","preventionTips":["Pair every `type: 'nfs'` synced folder with a static private_network ip in the template","On Linux hosts prefer nfs over virtualbox folders but keep the ip/host adapter subnet in sync","After host-only adapter changes on the host, `vagrant reload` before retrying NFS mounts"],"tags":["virtualbox","nfs","synced-folder","hostonly","network"],"backgroundTag":"nfs-requires-private-network","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}