339

I tried to use

sudo service networking restart

and

sudo /etc/init.d/network restart

but they both crash the window manager and I can no longer use my keyboard for input into X.

when I use the /etc/init.d/ method it complains saying that I should use the service utility

e.g. service networking restart

but it crashes just the same.

Is there a GUI method of restarting networking?

Jorge Castro
  • 73,717
waspinator
  • 4,942

18 Answers18

362

For Desktops

Try

sudo service network-manager restart

Or on recent Ubuntu versions:

sudo systemctl restart systemd-networkd

instead.

Ubuntu uses network-manager instead of the traditional Linux networking model. so you should restart the network-manager service instead of the network service. Or use ifup/down.

For Servers

Check this answer.

Zanna
  • 72,312
jrg
  • 61,707
125

For Servers

Restarting networking on a desktop machine will cause dbus and a bunch of service to stop and never be started again, usually leading to the whole system being unusable.

As Ubuntu does event based network bring up, there quite simply isn't a way to undo it all and redo it all, so a restart just isn't plain possible. The recommended way instead is to use ifdown and ifup on the interfaces you actually want to reconfigure:

sudo ifdown --exclude=lo -a && sudo ifup --exclude=lo -a
Jorge Castro
  • 73,717
46

You could try

ifconfig eth0 down && ifconfig eth0 up

(or whatever your network interface is called) to restart the network.

Neojames
  • 1,744
23

ubuntu CLI: to restart the network service either

sudo /etc/init.d/networking restart

or

ifdown eth0
ifup eth0
Javier Rivera
  • 35,434
redlakpa
  • 265
21

For ubuntu server 18.04, this works :

sudo systemctl restart systemd-networkd
20

These days the most direct way to restart network services is to use systemd controls, namely the commandline systemd control utility systemctl. This command will restart the NetworkManager:

sudo systemctl restart NetworkManager.service

More information can be found here.

muru
  • 207,228
dagrha
  • 992
9

service network-manager restart doesn't work:

stop: Unknown job network-manager
start: Unknown job network-manager

The only thing that works is:

ifconfig eth0 down
ifconfig eth0 up
Seth
  • 59,332
George
  • 91
7
sudo service network-manager restart

nor:

sudo service networking restart

Doesn't work on Ubuntu server 14.04

only:

sudo ifdown eth0:0
sudo ifup eth0:0

Works. Change eth0:0 to your interface.

6

Try using the indicator (top menu bar) to disable and then enable networking.

jdthood
  • 12,625
6

I've got the same issue. Its a known bug https://bugs.launchpad.net/ubuntu/+source/dbus/+bug/1102507

Using service network-manager restart works through

Heidi
  • 77
6

I do not really think there's GUI method - by default at least.

I'm also not sure what do You mean by 'restarting networking service', but I feel that the following could help.

Before Ubuntu 16.04

sudo killall NetworkManager 

It kills NetworkManger which automatically restarts after this. It doesn't break the system.

Ubuntu 16.04

sudo killall NetworkManager && sudo NetworkManager

Based on my personal experience, it seems that in Ubuntu 16.04 NetworkManager does not always restart by itself and it's better to start it manually.

kcpr
  • 1,472
5

If you can restart the network using the applet of NetworkManager, you do not need to restart NetworkManager itself (at least, most of the time).

In that case to restart all the connections, use this code from a shell or in a script:

nmcli nm enable false
sleep 5
nmcli nm enable true 

Details can be found in the NetworkManagar command-line interface manual page.

Notice that these commands acts as the applet, so they do not need any additional privilege (no sudo or whatever).

Rmano
  • 32,167
4

In ubuntu 14.04 they have a new "feature" that makes it impossible to restart. Force the interface down and up works.

  sudo ip link set eth0 down
  sudo ip link set eth0 up
2

I am able to restart the network service on ubuntu with command.

 sudo systemctl restart network-manager
2

if ubuntu 14.04 Desktop or Server, you can restart you network by:

sudo -i
( ifdown $(ifquery --list -X lo|xargs echo) && ifup $(ifquery --list -X lo|xargs echo) )&
scue
  • 37
  • 3
1

An alternative approach for the server (as of Ubuntu 18.04):

  1. Install ifupdown2 package : apt install ifupdown2

  2. Use service networking restart command

MAQ
  • 141
1

rmano's answer is brilliant. Solves so many issues.

Remark to improve: In U15 I experience a different syntax for nmcli:

For analysis do:

nmcli networking connectivity

To stop service do:

nmcli networking off

and to restart do:

nmcli networking on

No sudo required. Thanks rmano!

muru
  • 207,228
opinion_no9
  • 1,072
1

This uses Ubuntu's network-manager to disable, then enable eth0:

nmcli nm enable false eth0 && nmcli nm enable true eth0

If your connection has a different name, use it. You can learn your connections name by using the command:

nmcli c status
muru
  • 207,228