Ubuntu: How to restart the networking service?
Channel: Roel Van de Paar
Date: 2019-06-19

Ubuntu: How to restart the networking service?


Question: 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?

Solutions Sample (Please watch the whole video to see all solutions, in order of how many people found them helpful):

== This solution helped 107 people ==
***** 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

== This solution helped 1 person ==
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!

== This solution helped 1 person ==
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

== This solution helped 20 people ==
ubuntu CLI: to restart the network service either
sudo /etc/init.d/networking restart
or
ifdown eth0
ifup eth0

== This solution helped 250 people ==
***** For Desktops *****
Try
sudo service network-manager restart
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 https://askubuntu.com/a/376586/235.
***** For Servers *****
Check https://askubuntu.com/a/376586/6005.

== This solution helped 2 people ==
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) )&

== This solution helped 34 people ==
You could try
ifconfig eth0 down && ifconfig eth0 up
(or whatever your network interface is called) to restart the network.

== This solution helped 3 people ==
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.

With thanks & praise to God! With thanks to all the many who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music & music license: https://www.bensound.com/royalty-free-music | Images & images license: https://stocksnap.io/license and others | With thanks to user waspinator (https://askubuntu.com/users/22401), user slingshot (https://askubuntu.com/users/308803), user Seth (https://askubuntu.com/users/44179), user scue (https://askubuntu.com/users/397341), user Rmano (https://askubuntu.com/users/16395), user redlakpa (https://askubuntu.com/users/266024), user opinion_no9 (https://askubuntu.com/users/354678), user Neojames (https://askubuntu.com/users/76209), user muru (https://askubuntu.com/users/158442), user kcpr (https://askubuntu.com/users/59600), user jrg (https://askubuntu.com/users/6005), user Jorge Castro (https://askubuntu.com/users/235), user Jorge Castro (https://askubuntu.com/users/235), user jdthood (https://askubuntu.com/users/29569), user Javier Rivera (https://askubuntu.com/users/211), user Heidi (https://askubuntu.com/users/174329), user George (https://askubuntu.com/users/258249), user Gabriel Curio (https://askubuntu.com/users/355611), user dagrha (https://askubuntu.com/users/283025), user Alexander Kim (https://askubuntu.com/users/310264), and the Stack Exchange Network (http://askubuntu.com/questions/230698). Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything should be amiss at Roel D.OT VandePaar A.T gmail.com.