it happens when you have dynamic ip on your ubuntu server and suddenly your ip has changed and you have problems connecting with your local services because of ip change. here the solution

sudo apt-get install network-manager

Networking is handled by netplan by default in Ubuntu Server 18. I suggest that you edit the /etc/netplan/01-netcfg.yaml file to read:

nano /etc/netplan/01-netcfg.yaml

and add the next and modify the ip according to your local ip. In my case, my ip was going to be

# For more information, see netplan(5).
  version: 2
  renderer: networkd
      dhcp4: no
      dhcp6: no
      addresses: []
          addresses: [,]

Exit and save your changes by running the command:

sudo netplan apply

Please note and follow the spacing and indentation. then restart network

service network-manager restart

Comment out all the ens33 stanzas in /etc/network/interfaces. Reboot.