How to restart the networking service?
Solution 1
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.
Solution 2
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
Solution 3
You could try
ifconfig eth0 down && ifconfig eth0 up
(or whatever your network interface is called) to restart the network.
Solution 4
ubuntu CLI: to restart the network service either
sudo /etc/init.d/networking restart
or
ifdown eth0
ifup eth0
Solution 5
For ubuntu server 18.04, this works :
sudo systemctl restart systemd-networkd
Related videos on Youtube
waspinator
Updated on September 18, 2022Comments
-
waspinator over 1 year
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 utilitye.g. service networking restart
but it crashes just the same.
Is there a GUI method of restarting networking?
-
Admin almost 11 yearsI also faced similar issue on Gnome 3 on Ubuntu 13.03. Screen disorted as top bar gone. Short keys not worked. As no menu/Activies shown I get no way to operate the system. Luckily console was opened already. So reboot command can be typed.
-
Admin over 9 yearsif you are looking for GUI method just open dash, type "Network" and select that. now press "On/Off" button to turn off and again click to on. your networking is restarted now.
-
-
Marilou over 10 yearsI'm getting
ifup: failed to open lockfile /run/network/.ifstate.lock: Permission denied
even on--force
-
aProperFox over 10 years@waspinator - it happens to me too. (FYI.)
-
waspinator almost 10 years@Jorge Castro: is this behavior going to be fixed, or is it broken by design?
-
Jorge Castro almost 10 years@waspinator the bug is marked fixed as of march of this year: bugs.launchpad.net/ubuntu/+source/dbus/+bug/1072518
-
Samveen almost 10 yearsThis does not restart the network services, that is, no retry for DHCP addresses etc.
-
moritz about 9 years... as far as I know, this doesn't update the interface's config according to /etc/network/interfaces ... which you might want
-
tarkeshwar about 9 yearsWhen using sudo: sudo ifconfig eth0 down && sudo ifconfig eth0 up. Otherwise if you are connected over ssh, you will have to reboot machine.
-
wolfgang over 8 yearsI get a
ifdown: interface eth0 not configured RTNETLINK answers: File exists Failed to bring up eth0.
-
Jon B over 8 yearsafter trying ifup/ifdown and the reg service networking call, this finally worked for me
-
Jeff Atwood over 8 yearswhat's the purpose of
exclude=lo
here? -
Abdennour TOUMI over 8 yearsAutocomplete give
networking
, however , the right cmd isnetwork-manager
-
SomeoneSomewhereSupportsMonica almost 8 years@JeffAtwood Loopback is used for X, dbus etc. Disabling it causes... issues.
-
Derek Mahar over 7 yearsWorked on Ubuntu Server 16.04.1. Ubuntu Server doesn't appear to include Network Manager, so askubuntu.com/a/230751/13756 doesn't work.
-
cloudsurfin over 7 yearsTry "systemctl restart networking.service" on server 16.04.
-
Underverse over 7 yearsHow is this better than
sudo service network-manager restart
and why? -
danijelc over 7 yearsThis is solution which works always on 16.04. In my experience Ubuntu 16.04 have issues to restart Wi-Fi after returning from hibernation.
-
kcpr over 7 years@Underverse, I believe that
sudo service network-manager restart
just didn't work for me when posting this answer. -
josircg about 7 yearsThis used to work for older kernels. Now it seems that do not work indeed. Prefered ifconfig eth0 down & ifconfig eth0 up
-
Jonathan about 7 yearsI wish I had tried Jorge's answer first.
-
Nikolay Kostov almost 7 yearsBeware not to use this command when connecting on remote machine.
-
gilad905 almost 6 yearsI think it's better than the accepted answer because
ifup
doesn't handle bonded interfaces correctly, whileifconfig
does -
Eduardo Lucio over 5 yearsThe
ifdown --exclude=lo -a && ifup --exclude=lo -a
command did not work for Ubuntu Server 14.04. Theifconfig eth0 down && ifconfig eth0 up
command worked (askubuntu.com/a/230804/134723). -
Gringo Suave over 5 yearsDon't need the ".service" part at the end.
-
van abel over 5 yearsThus save my life, since I run
/etc/init.d/iptables restart
on my VPS, which turns the host has no ip address even after reboot. This solves my problem. -
Ejoso about 5 yearsAs of 18.04.2 the answer is:
systemctl restart systemd-networkd
-
LandiLeite almost 4 yearsTo new LTS 20.04 the comand above work, thanks!
-
user643722 over 3 yearsOn my Desktop system this answer gave me
Failed to restart network-manager.service: Unit network-manager.service not found.
I found the answer from @dagrha seems to work. -
Mohammed Noureldin over 2 yearsI confirm! This works on 20.04! Thanks!
-
Moritz Friedrich over 2 yearsWhy oh why do they change the name every year. Sigh. That works on 20.04.