Save 10%Pay yearly on any plan. 6% half-yearly, 3% quarterly. Help centreWhatsAppTelegram TeamsOpen a ticket

How to Restart the Network in Ubuntu

The commands that restart networking on current Ubuntu Server and Desktop, how to do it safely over SSH, and what to check when it does not help.

2 min readBy Soumya

Reviewed by the AmazingRDP technical team

Restarting the network in Ubuntu

A Linux VPS comes with its network set up and a console that works even when the network does not. See Linux VPS from $6.99

After changing network settings, or when a connection hangs, restarting the network is quicker than restarting the machine. Which command does it depends on what manages the network, and the commands in many guides (systemctl restart networking, ifdown and ifup) no longer exist on current Ubuntu. Here are the ones that do.

First: what manages your network?

systemctl is-active NetworkManager systemd-networkd

Two answers come back, one per line. Ubuntu Server normally shows inactive then active: it uses systemd-networkd, configured through Netplan. Ubuntu Desktop shows active first: it uses NetworkManager.

Ubuntu Server

Apply the Netplan settings again:

sudo netplan apply

This is the right command after editing a file in /etc/netplan/. To restart the network service itself:

sudo systemctl restart systemd-networkd

To see the result:

networkctl status
ip -br addr

Ubuntu Desktop

sudo systemctl restart NetworkManager

Or without sudo, switch networking off and on:

nmcli networking off && nmcli networking on

With the mouse: open the menu at the top right, switch the connection off, wait a few seconds, and switch it on again.

One interface only

ip -br link
sudo ip link set ens18 down && sudo ip link set ens18 up

The first line shows the interface names; use yours in the second. On a desktop with NetworkManager:

nmcli device disconnect ens18 && nmcli device connect ens18

Over SSH: do not cut the branch you sit on

  • Write "down" and "up" in one line joined with &&, as above. If you send "down" alone, your session is gone before you can type "up".
  • After changing settings, use sudo netplan try in place of apply. It puts the old settings back after two minutes unless you confirm. See how to configure a static IP on Ubuntu Server.
  • Know where your provider's console is. It reaches the server when the network does not.

Only names fail? Restart DNS, not the network

If ping 1.1.1.1 works but ping example.com does not, the connection is fine and name lookups are the problem:

sudo resolvectl flush-caches
sudo systemctl restart systemd-resolved
resolvectl status

Get a new address from DHCP

sudo networkctl renew ens18

On a desktop, switching the connection off and on does the same.

When restarting does not help

CheckCommandWhat it tells you
Is the link up?ip -br link"DOWN" or "NO-CARRIER" means cable, Wi-Fi or the virtual network card
Is there an address?ip -br addrNo address: DHCP or the static settings failed
Is there a route out?ip routeNo "default" line: the gateway is missing
What went wrong?journalctl -u systemd-networkd -bThe service's messages since the last start

Old commands, for reference

sudo systemctl restart networking and sudo ifdown eth0 && sudo ifup eth0 belong to the "ifupdown" system that Ubuntu used up to version 16.04. They work only if you installed that package yourself. service network-manager restart is the old name of the NetworkManager command above.

Our Linux VPS plans come with the network configured. Related guides: open or block a port in the Ubuntu firewall and why Ubuntu freezes and how to fix it.

Questions

What is the command to restart the network in Ubuntu?

On Ubuntu Server, sudo netplan apply or sudo systemctl restart systemd-networkd. On Ubuntu Desktop, sudo systemctl restart NetworkManager.

Why does "systemctl restart networking" not work?

That service belongs to the older ifupdown system, which current Ubuntu versions no longer use.

How do I restart the network without losing my SSH connection?

Put the down and up commands in one line, or use sudo netplan try, which reverts if you do not confirm.

Do I need to reboot to apply network changes?

No. sudo netplan apply applies them at once.