{"record":{"id":"7631525828c44b48","repo":"hashicorp/vagrant","slug":"the-adapter-to-attach-a-forwarded-port-to-was-not","errorCode":null,"errorMessage":"The adapter to attach a forwarded port to was not found. Please\nverify that the given adapter is setup on the machine as a NAT\ninterface.\n\nHost port: %{host}\nGuest port: %{guest}\nAdapter: %{adapter}","messagePattern":"The adapter to attach a forwarded port to was not found\\. Please\nverify that the given adapter is setup on the machine as a NAT\ninterface\\.\n\nHost port: %(.+?)\nGuest port: %(.+?)\nAdapter: %(.+?)","errorType":"exception","errorClass":"Vagrant::Errors::ForwardPortAdapterNotFound","httpStatus":null,"severity":"error","filePath":"plugins/providers/virtualbox/action/forward_ports.rb","lineNumber":58,"sourceCode":"          interfaces = @env[:machine].provider.driver.read_network_interfaces\n\n          @env[:forwarded_ports].each do |fp|\n            message_attributes = {\n              adapter: fp.adapter,\n              guest_port: fp.guest_port,\n              host_port: fp.host_port\n            }\n\n            # Assuming the only reason to establish port forwarding is\n            # because the VM is using Virtualbox NAT networking. Host-only\n            # bridged networking don't require port-forwarding and establishing\n            # forwarded ports on these attachment types has uncertain behaviour.\n            @env[:ui].detail(I18n.t(\"vagrant.actions.vm.forward_ports.forwarding_entry\",\n                                    **message_attributes))\n\n            # Verify we have the network interface to attach to\n            if !interfaces[fp.adapter]\n              raise Vagrant::Errors::ForwardPortAdapterNotFound,\n                adapter: fp.adapter.to_s,\n                guest: fp.guest_port.to_s,\n                host: fp.host_port.to_s\n            end\n\n            # Port forwarding requires the network interface to be a NAT interface,\n            # so verify that that is the case.\n            if interfaces[fp.adapter][:type] != :nat\n              @env[:ui].detail(I18n.t(\"vagrant.actions.vm.forward_ports.non_nat\",\n                                    **message_attributes))\n              next\n            end\n\n            # Add the options to the ports array to send to the driver later\n            ports << {\n              adapter:   fp.adapter,\n              guestip:   fp.guest_ip,\n              guestport: fp.guest_port,","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/providers/virtualbox/action/forward_ports.rb#L40-L76","documentation":"Before creating a NAT port-forward rule, the ForwardPorts action looks up the VM's network adapters (read_network_interfaces) and requires an entry at the forwarded port's adapter number. If interfaces[fp.adapter] is nil it raises ForwardPortAdapterNotFound, because VBoxManage would fail attaching the rule to a nonexistent NIC.","triggerScenarios":"A forwarded-port definition with `adapter:` set to an index the VM does not have — e.g. `config.vm.network 'forwarded_port', guest: 80, host: 8080, adapter: 2` on a VM with only one NIC; or custom `config.vm.customize ['modifyvm', :id, '--nic2', 'none']` style tweaks removing the adapter.","commonSituations":"Copy-pasted Vagrantfiles that pin adapter numbers; boxes whose base OVF defines fewer NICs than expected; customizations that disable NICs; port-forward blocks inherited from another project with more networks defined.","solutions":["Remove the `adapter:` option from the forwarded_port definition and let Vagrant pick the default (0/1)","Ensure a network actually exists on that index, e.g. add `config.vm.network 'private_network', ip: ...` so adapter 2 exists before pinning adapter: 2","Check current NICs: `VBoxManage showvminfo <name> | grep -i nic` and align adapter numbers with what exists","Remove customize blocks that set '--nicN' to none/empty while forwarding ports on that index"],"exampleFix":"# Vagrantfile - before:\nconfig.vm.network 'forwarded_port', guest: 80, host: 8080, adapter: 2  # VM has 1 NIC\n\n# after (option A - drop the pin):\nconfig.vm.network 'forwarded_port', guest: 80, host: 8080\n# after (option B - create the adapter):\nconfig.vm.network 'private_network', ip: '192.168.56.10'\nconfig.vm.network 'forwarded_port', guest: 80, host: 8080, adapter: 2","handlingStrategy":"validation","validationCode":"# before up, reconcile forwarded_port adapter indexes with real NICs\nnics = `VBoxManage showvminfo <name> --machinereadable`.scan(/^nic(\\d+)=\"(?!none)/).map { |n| n.first.to_i }\nports = [{ host: 8080, guest: 80, adapter: 2 }]\nbad = ports.select { |p| p[:adapter] && !nics.include?(p[:adapter]) }\nabort \"adapter #{bad.first[:adapter]} missing on VM\" unless bad.empty?","typeGuard":null,"tryCatchPattern":"begin\n  env.cli('up')\nrescue Vagrant::Errors::ForwardPortAdapterNotFound => e\n  d = e.extra_data\n  warn \"No NIC #{d[:adapter]} for #{d[:host]}->#{d[:guest]}; drop `adapter:` or add a network on that index\"\nend","preventionTips":["Avoid pinning `adapter:` unless you also define the matching config.vm.network","Audit Vagrantfiles copied between projects for leftover adapter numbers","Do not combine NIC-disabling customize blocks with forwarded ports on those indexes"],"tags":["virtualbox","forwarded-port","network-adapter","nat"],"backgroundTag":"network-adapter-not-found","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}