Vagrant: Vagrant should recover from bad nat.json

Created on 27 Feb 2019  ·  5Comments  ·  Source: hashicorp/vagrant

Vagrant version

Vagrant 2.2.3
vagrant-vmware-desktop (2.0.3, global)
vmware tool 1.0.7

Host operating system

OSX 10.14.3

Guest operating system

n/a

Vagrantfile

n/a

Debug output

Vagrant failed to apply the requested port forward. The following
error message was generated while attempting to apply the port
forward rule:

Port forward conflict on host port 3389

Please resolve any problems reported in the error message above and
try again.

Expected behavior

Start the VM.
I am opening this bug to point out that vagrant / vmware-plugin / vmware tool doesn't recover from nat.json with some leftover content. Can you please implement some sort of health check to handle such situations?

Actual behavior

VM was started but vagrant itself quit before provisioning could take place

Steps to reproduce

  1. TBH, I am unsure how I arrived at this situation. I think I may have interrupted vagrant up with Ctrl+C.

References

This issue seems to be sort of related to https://github.com/hashicorp/vagrant/issues/10575 , Or at least the solution provided worked.

Content _bad_ of nat.json:

{
  "fwds": [
    {
      "enable": false,
      "device": "8",
      "protocol": "tcp",
      "hostport": 3389,
      "guestip": "172.16.200.140",
      "guestport": 3389,
      "description": "vagrant: /users/mm/.vagrant.d/clones/2f47b8d7-8d8f-4a5a-9831-452867917989/windows_2012_r2_base.vmx"
    },
    {
      "enable": false,
      "device": "8",
      "protocol": "tcp",
      "hostport": 2222,
      "guestip": "172.16.200.140",
      "guestport": 22,
      "description": "vagrant: /users/mm/.vagrant.d/clones/2f47b8d7-8d8f-4a5a-9831-452867917989/windows_2012_r2_base.vmx"
    },
    {
      "enable": false,
      "device": "8",
      "protocol": "tcp",
      "hostport": 13389,
      "guestip": "172.16.200.140",
      "guestport": 3389,
      "description": "vagrant: /users/mm/.vagrant.d/clones/2f47b8d7-8d8f-4a5a-9831-452867917989/windows_2012_r2_base.vmx"
    },
    {
      "enable": false,
      "device": "8",
      "protocol": "tcp",
      "hostport": 55985,
      "guestip": "172.16.200.140",
      "guestport": 5985,
      "description": "vagrant: /users/mm/.vagrant.d/clones/2f47b8d7-8d8f-4a5a-9831-452867917989/windows_2012_r2_base.vmx"
    },
    {
      "enable": false,
      "device": "8",
      "protocol": "tcp",
      "hostport": 55986,
      "guestip": "172.16.200.140",
      "guestport": 5986,
      "description": "vagrant: /users/mm/.vagrant.d/clones/2f47b8d7-8d8f-4a5a-9831-452867917989/windows_2012_r2_base.vmx"
    },
    {
      "enable": false,
      "device": "8",
      "protocol": "tcp",
      "hostport": 10000,
      "guestip": "172.16.200.141",
      "guestport": 3389,
      "description": "vagrant: /users/mm/.vagrant.d/clones/e31de858-40a4-48c3-be42-fc3a85a33953/windows_2012_r2_base.vmx"
    }
  ]
}
bug providevmware

Most helpful comment

Hi. This issue has been addressed in the latest release of the Vagrant VMware utility (v1.0.12). Upgrading will resolve this issue.

Cheers!

All 5 comments

This is happening more and more frequently and it is a big nuisance to keep SSHing into the machine to manually recover this file.

I struggled on two MBP in the last few days. All updated to latest versions Vagrant 2.2.5, vagrant-vmware-utility 1.0.7, vagrant-vmware-desktop plugin 2.0.3, VMware Fusion Pro 11.1.0 but the port conflict stopped me from using Vagrant. OK, the VM starts, but I cannot provision or use the shared folder.

Now I've deleted all port forwardings in

sudo vi "/Library/Preferences/VMware Fusion/vmnet2/nat.conf"
sudo vi "/Library/Preferences/VMware Fusion/networking"
rm -rf .vagrant

rebooted and ran a fresh vagrant up, but the error still exists.

$ vagrant up 2019-box
Bringing machine '2019-box' up with 'vmware_fusion' provider...
==> 2019-box: Cloning VMware VM: 'StefanScherer/windows_2019_docker'. This can take some time...
==> 2019-box: Checking if box 'StefanScherer/windows_2019_docker' version '2019.07.11' is up to date...
==> 2019-box: Verifying vmnet devices are healthy...
==> 2019-box: Preparing network adapters...
==> 2019-box: Starting the VMware VM...
==> 2019-box: Waiting for the VM to receive an address...
==> 2019-box: Forwarding ports...
    2019-box: -- 5985 => 55985
    2019-box: -- 5986 => 55986
    2019-box: -- 22 => 2222
Vagrant failed to apply the requested port forward. The following
error message was generated while attempting to apply the port
forward rule:

  Port forward conflict on host port 55986

Please resolve any problems reported in the error message above and
try again.

After I found this blog post https://www.cryptica.me/blog/port-forward-collision/ I additionally did

sudo rm -f /opt/vagrant-vmware-desktop/settings/nat.json
sudo killall vagrant-vmware-utility
vagrant up

And it works again 😅

I've saved my bad nat.json

{
  "fwds": [
    {
      "enable": false,
      "device": "8",
      "protocol": "tcp",
      "hostport": 2213,
      "guestip": "192.168.65.165",
      "guestport": 3389,
      "description": "vagrant: /users/stefan/code/jh2019/.vagrant/machines/default/vmware_desktop/f4a75ddc-614b-4b32-ba36-27640f49b5fc/windows_10.vmx"
    },
    {
      "enable": false,
      "device": "8",
      "protocol": "tcp",
      "hostport": 2215,
      "guestip": "192.168.65.165",
      "guestport": 5985,
      "description": "vagrant: /users/stefan/code/jh2019/.vagrant/machines/default/vmware_desktop/f4a75ddc-614b-4b32-ba36-27640f49b5fc/windows_10.vmx"
    },
    {
      "enable": false,
      "device": "8",
      "protocol": "tcp",
      "hostport": 2221,
      "guestip": "192.168.65.165",
      "guestport": 5986,
      "description": "vagrant: /users/stefan/code/jh2019/.vagrant/machines/default/vmware_desktop/f4a75ddc-614b-4b32-ba36-27640f49b5fc/windows_10.vmx"
    },
    {
      "enable": false,
      "device": "8",
      "protocol": "tcp",
      "hostport": 2223,
      "guestip": "192.168.65.165",
      "guestport": 22,
      "description": "vagrant: /users/stefan/code/jh2019/.vagrant/machines/default/vmware_desktop/f4a75ddc-614b-4b32-ba36-27640f49b5fc/windows_10.vmx"
    },
    {
      "enable": false,
      "device": "8",
      "protocol": "tcp",
      "hostport": 3389,
      "guestip": "192.168.65.130",
      "guestport": 3389,
      "description": "vagrant: /users/stefan/code/jh2019/.vagrant/machines/default/vmware_desktop/3139d6d1-c109-4bdc-8446-dd01eb19316a/windows_10.vmx"
    },
    {
      "enable": false,
      "device": "8",
      "protocol": "tcp",
      "hostport": 2200,
      "guestip": "192.168.65.130",
      "guestport": 5985,
      "description": "vagrant: /users/stefan/code/jh2019/.vagrant/machines/default/vmware_desktop/3139d6d1-c109-4bdc-8446-dd01eb19316a/windows_10.vmx"
    },
    {
      "enable": false,
      "device": "8",
      "protocol": "tcp",
      "hostport": 55986,
      "guestip": "192.168.65.130",
      "guestport": 5986,
      "description": "vagrant: /users/stefan/code/jh2019/.vagrant/machines/default/vmware_desktop/3139d6d1-c109-4bdc-8446-dd01eb19316a/windows_10.vmx"
    },
    {
      "enable": false,
      "device": "8",
      "protocol": "tcp",
      "hostport": 2222,
      "guestip": "192.168.65.130",
      "guestport": 22,
      "description": "vagrant: /users/stefan/code/jh2019/.vagrant/machines/default/vmware_desktop/3139d6d1-c109-4bdc-8446-dd01eb19316a/windows_10.vmx"
    },
    {
      "enable": false,
      "device": "8",
      "protocol": "tcp",
      "hostport": 55985,
      "guestip": "192.168.65.130",
      "guestport": 5985,
      "description": "vagrant: /users/stefan/code/windows-docker-machine/.vagrant/machines/2019-box/vmware_fusion/ad988250-745b-4544-82e6-ac521d992c35/windowsserver2019docker.vmx"
    }
  ]
}

Yep, seriously frustrated by this. Using latest plugin and fusion 12 on catalina. this is killing my productivity more than helping it.

Hi. This issue has been addressed in the latest release of the Vagrant VMware utility (v1.0.12). Upgrading will resolve this issue.

Cheers!

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

Related issues

dorinlazar picture dorinlazar  ·  3Comments

jazzfog picture jazzfog  ·  3Comments

Cbeck527 picture Cbeck527  ·  3Comments

StefanScherer picture StefanScherer  ·  3Comments

jsirex picture jsirex  ·  3Comments