Connection problem while switching between virtual machine and controller

How solve this issues?

Connection problems when using controller after using virtual machine can be the cause of an active virtual machine network adaptor for example vboxnet0

Open terminal type: ifconfig, check for adaptor vboxnet0:

vboxnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.56.1  netmask 255.255.255.0  broadcast 192.168.56.255
        inet6 fe80::800:27ff:fe00:0  prefixlen 64  scopeid 0x20<link>
        ether 0a:00:27:00:00:00  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 1  overruns 0  frame 0
        TX packets 95  bytes 13572 (13.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Shut down vboxnet0

Run the command sudo ifconfig vboxnet0 down, to close the virtual machine network adaptor connection. This will remove vboxnet0 from ifconfig list.

Start up vboxnet0

Run the command sudo ifconfig vboxnet0 up, to activate the virtual machine network adaptor connection. This will add vboxnet0 to ifconfig list.