Network services in Linux can be restarted with a single command that refreshes connections without a full system reboot. If you are wondering how to restart network service in linux, you have come to the right place. This guide covers every major method, from the classic sysvinit commands to modern systemd tools, plus network manager tricks and troubleshooting tips. By the end, you will be able to fix most network glitches in seconds.
Whether you are a sysadmin managing servers or a desktop user who just lost internet, restarting the network service is often the quickest fix. It clears stale routes, renews DHCP leases, and resets interface states. Let us walk through each approach step by step.
How To Restart Network Service In Linux
This section covers the most common and reliable methods. The exact command depends on your Linux distribution and init system. Most modern distros use systemd, but older ones rely on SysVinit scripts or the network service manager.
Using Systemd (Modern Distributions)
Systemd is the default init system for Ubuntu 16.04+, Debian 8+, CentOS 7+, RHEL 7+, Fedora, and many others. The command is simple and consistent.
- Open a terminal with root privileges or use sudo.
- Type the following command to restart the network service:
sudo systemctl restart networking
On some distributions like CentOS or RHEL, the service name might be network instead of networking. So try:
sudo systemctl restart network
If you are using NetworkManager (common on desktops and some servers), restart it like this:
sudo systemctl restart NetworkManager
You can check the status after restarting with:
sudo systemctl status networking
This shows if the service is active and running. If you see errors, the output will help diagnose the issue.
Using SysVinit Scripts (Older Distributions)
For older systems like CentOS 6, Debian 7, or Ubuntu 14.04, the init system is SysVinit. The command uses the service wrapper or direct script path.
- Run the following as root or with sudo:
sudo service networking restart
Or for the network service:
sudo /etc/init.d/networking restart
On Red Hat based systems, you might use:
sudo service network restart
These commands stop and then start the network service. You might see a brief interruption, but connections should come back quickly.
Using Ifdown And Ifup Commands
Another approach is to bring interfaces down and up individually. This is useful if you only want to restart one interface without affecting others.
- Identify your network interface name with:
ip link show
Common names are eth0, enp3s0, wlan0, or ens33.
- Bring the interface down:
sudo ifdown eth0
- Then bring it back up:
sudo ifup eth0
This method is gentler than restarting the whole service. It only affects the specified interface. You can also use the newer ip command:
sudo ip link set eth0 down
sudo ip link set eth0 up
But ifup/ifdown often handle DHCP renewal and routing table updates automatically.
Using NetworkManager Command Line (Nmcli)
If your system uses NetworkManager, you can restart networking via its CLI tool. This is handy for scripting or remote management.
- Check the status of connections:
nmcli general status
- To restart the entire NetworkManager service:
sudo systemctl restart NetworkManager
- Or reconnect a specific connection by name:
nmcli connection down "Your Connection Name"
nmcli connection up "Your Connection Name"
This is especially useful on laptops that switch between Wi-Fi and Ethernet. It avoids dropping all connections at once.
Common Scenarios And Troubleshooting
Sometimes the restart command does not work as expected. Here are typical issues and how to fix them.
Service Name Differences
Not all distributions use the same service name. If networking or network fails, try these alternatives:
systemctl restart systemd-networkd(on systems using systemd-networkd)systemctl restart wpa_supplicant(for Wi-Fi issues)systemctl restart dhcpcd(on Arch Linux or derivatives)
You can list all active services with:
systemctl list-units --type=service --state=running
Look for anything with “network” in the name.
Permission Denied Errors
If you get a permission error, you likely forgot sudo. Always prefix commands with sudo or run as root. If sudo is not installed, switch to root with su -.
Network Service Not Found
Some minimal Docker containers or embedded systems do not have a network service manager. In that case, you might need to restart the container or use ip link commands directly. For example:
sudo ip link set eth0 down && sudo ip link set eth0 up
This works even without systemd.
Configuration File Errors
If the restart fails, check your network configuration files. Common locations include:
/etc/network/interfaces(Debian/Ubuntu)/etc/sysconfig/network-scripts/ifcfg-*(RHEL/CentOS)/etc/netplan/*.yaml(Ubuntu 18.04+)
Look for syntax errors, missing parameters, or duplicate entries. After fixing, restart the service again.
Stuck Or Hung Interfaces
Sometimes an interface refuses to come up. Try releasing and renewing the DHCP lease:
sudo dhclient -r eth0
sudo dhclient eth0
Or use nmcli to disconnect and reconnect. If all else fails, reboot the system.
Automating Network Restarts With Scripts
If you find yourself restarting the network often, write a simple script. Here is an example for systemd:
#!/bin/bash
echo "Restarting network service..."
sudo systemctl restart networking
echo "Network service restarted successfully."
Save it as restart-network.sh, make it executable with chmod +x restart-network.sh, and run it when needed. You can even add it to cron for scheduled restarts.
For NetworkManager, a more robust script might look like:
#!/bin/bash
nmcli connection down "MyConnection"
sleep 2
nmcli connection up "MyConnection"
This avoids restarting the entire service, which might disrupt other connections.
Understanding What Happens During A Network Restart
When you restart the network service, several things occur in sequence:
- All network interfaces are taken down gracefully.
- Routing tables are flushed.
- DHCP leases are released (if using DHCP).
- ARP caches are cleared.
- Interfaces are brought back up with their configured settings.
- DHCP requests are sent to obtain new IP addresses.
- Routing tables are rebuilt based on new interface states.
This process usually takes less than a second. However, if DNS resolution fails after restart, you might need to restart the DNS resolver as well:
sudo systemctl restart systemd-resolved
Or flush the DNS cache with:
sudo systemd-resolve --flush-caches
When To Restart Network Service Vs Reboot
Restarting the network service is faster and less disruptive than a full reboot. Use it when:
- You changed network configuration files.
- You lost connectivity after a suspend/resume cycle.
- You want to renew a DHCP lease.
- You are troubleshooting intermittent drops.
Reboot only if the network service restart fails repeatedly, or if you have kernel-level network issues that require a fresh boot.
Distro-Specific Commands
Here is a quick reference table for popular distributions:
| Distribution | Command |
|---|---|
| Ubuntu 16.04+ | sudo systemctl restart networking |
| Debian 8+ | sudo systemctl restart networking |
| CentOS 7+ | sudo systemctl restart network |
| RHEL 7+ | sudo systemctl restart network |
| Fedora | sudo systemctl restart NetworkManager |
| Arch Linux | sudo systemctl restart systemd-networkd |
| OpenSUSE | sudo systemctl restart network |
| Slackware | /etc/rc.d/rc.inet1 restart |
If your distro is not listed, check its documentation or try both networking and network service names.
Advanced: Restarting Network With Nmcli In Scripts
For headless servers or automated tasks, nmcli is a powerful tool. Here is how to restart all connections gracefully:
#!/bin/bash
for con in $(nmcli -t -f NAME connection show); do
nmcli connection down "$con"
nmcli connection up "$con"
done
This loops through every connection and restarts them one by one. Add a sleep between each if you want to avoid race conditions.
Security Considerations
Restarting network services usually requires root privileges. Never give sudo access to untrusted users for network commands. Also, be aware that restarting the network will terminate active SSH sessions if you are connected remotely. Use a screen or tmux session, or schedule the restart during maintenance windows.
If you must restart remotely, consider using a command that reconnects automatically, or have a backup console access.
Frequently Asked Questions
Q: How do I restart network service in Linux without sudo?
A: You cannot restart the network service without root privileges. However, you can use nmcli to reconnect your user’s connections if NetworkManager is configured for user control.
Q: What is the difference between restarting networking and NetworkManager?
A: The networking service manages interfaces via configuration files like /etc/network/interfaces. NetworkManager is a higher-level service that handles dynamic connections, Wi-Fi, and user profiles. Restarting one does not affect the other unless they conflict.
Q: How to restart network service in linux permanently after changes?
A: To make changes persistent, edit the configuration files and then restart the service. The restart applies the changes immediately and they will survive reboots.
Q: Why does my network restart fail with “Failed to restart networking.service: Unit networking.service not found”?
A: This means your distribution uses a different service name. Try network, NetworkManager, or systemd-networkd. Use systemctl list-units | grep network to find the correct name.
Q: Can I restart network service in linux without losing SSH connection?
A: It is risky. If you restart the entire service, your SSH session might drop. Safer methods include restarting only the specific interface or using nmcli to reconnect. Always have a fallback like iDRAC, IPMI, or a second SSH session.
Final Tips For Smooth Network Restarts
Always verify your configuration files before restarting. A typo can leave you without network access. Use tools like netplan try (on Ubuntu) to test changes before applying them permanently.
Keep a backup of your working configuration. If something goes wrong, you can restore it quickly. Also, consider using a network manager like NetworkManager for desktop environments, as it handles reconnections automatically.
Remember that restarting the network service is a safe operation, but it does cause a brief interruption. Plan accordingly if you are running critical services. For production servers, use load balancers or redundant interfaces to minimize downtime.
Now you know exactly how to restart network service in linux. Whether you prefer systemctl, service, ifup/ifdown, or nmcli, you have the tools to fix network issues fast. Practice these commands in a test environment first, and you will be ready for any network hiccup.