Applies to: Ubuntu 24.04 LTS (netplan 1.1.2, systemd 255, NetworkManager 1.46) and Ubuntu 26.04 LTS (netplan 1.2, systemd 259); tested on both
On Ubuntu Server the network is configured by netplan and run by systemd-networkd. After you change a file in /etc/netplan/, the right way to “restart the network” is:
sudo netplan apply
It prints nothing when it works. The old sudo systemctl restart networking and sudo service networking restart don’t exist on current Ubuntu; both answer Failed to restart networking.service: Unit networking.service not found.
Which command for which situation
- You edited a netplan YAML file:
sudo netplan apply(ornetplan tryfirst, see below). - The interfaces look stuck and you changed nothing:
sudo networkctl reconfigure eth0for one interface, orsudo systemctl restart systemd-networkdfor all of them. - You edited files in
/etc/systemd/network/by hand (not netplan):sudo networkctl reload. - Ubuntu Desktop (NetworkManager):
sudo systemctl restart NetworkManager, ornmcli networking offfollowed bynmcli networking on. Note the unit name:network-manager.serviceansweredUnit network-manager.service not found.in our test. - Only DNS is wrong: flush the resolver cache instead, see flush the DNS cache.
Replace eth0 with your interface name from ip -br addr.
Apply a change safely over SSH
A typo in a gateway or address can cut your SSH session. netplan try applies the change and rolls it back unless you confirm it:
- Edit the file, for example
sudo nano /etc/netplan/50-cloud-init.yaml(the name differs per server; check withls /etc/netplan/). - Run
sudo netplan try. The default timeout is 120 seconds;--timeout 30shortens it. - Open a new SSH session to check that you can still reach the server.
- If it works, go back and press Enter to keep the settings. If you lose the connection, just wait: when the timeout runs out, netplan restores the previous settings (our test printed
Reverting.).
Important: in our test, the rollback only restored the running settings. The edited YAML file stayed as it was, so the broken change would come back with the next netplan apply or reboot. Fix or undo the edit straight away.
Check the result
ip -br addr ip route networkctl list netplan get # shows the merged netplan configuration
After our test change, ip -br addr show br0 showed the new address (10.99.0.2/24) straight after netplan apply, without a reboot.
Warnings you may see
Permissions for /etc/netplan/50-test.yaml are too open. Netplan configuration should NOT be accessible by others.: in our test the change was still applied, but fix it withsudo chmod 600 /etc/netplan/*.yaml, as these files can contain Wi-Fi or VPN secrets./etc/netplan/50-test.yaml:7:4: Invalid YAML: inconsistent indentation: nothing was changed; fix the line and column it names. Indent with spaces, not tabs.
Restart the whole server instead
If you are not sure the new settings will work, have console access ready before you reboot: VNC console in Virtualizor for a VPS, or IPMI for a dedicated server. Then use sudo reboot; the reboot and shutdown commands are explained in shutdown, poweroff, halt and reboot.
Related: set a static IP with Netplan, old networking commands and their replacements, and install Ubuntu Server.