VPS Keeps Losing Connection

Is your Linux server acting flaky with intermittent connectivity? If your network interface (like eth0 or enp0s3) keeps bouncing up and down – that's flapping. It's a common nightmare for admins, causing packet loss, slow speeds, or total outages. Often tied to hardware glitches, bad configs, or driver drama, but fear not – we'll spot it and squash it.  

This guide is for beginner to intermediate Linux users (Ubuntu, CentOS, Debian, etc.). We'll use built-in tools – no extras needed. If you're on our Nebula Core VPS, SSH in as root and follow along.

Pro tip: Back up configs first with cp /etc/network/interfaces /etc/network/interfaces.bak or similar.

 

What Is Network Interface Flapping?

Flapping happens when a network port or route flips between "up" and "down" states rapidly – think seconds or minutes. It disrupts traffic, triggers alerts in monitoring tools, and can loop your server into instability.  

Common culprits: 

  • Faulty cables/adapters (e.g., damaged Ethernet). 
  • Driver/firmware bugs (especially on QLogic or Broadcom cards). 
  • Power management (ASPM/PCIE saving causing drops). 
  • Switch/router issues (MAC flapping, STP loops). 
  • Bonding/team setups gone wrong.

Spot it early to avoid bigger headaches like blacklisted IPs or downed services.

 

Step 1: Identify If Your Interface Is Flapping

Log in via SSH (or console in Nebula Core) and run these commands. Look for repeated up/down messages. 

  1. Check System Logs (dmesg):
    dmesg | grep eth (replace "eth" with your interface, e.g., enp0s3).
    Signs: Lines like "[eth0] link up" followed quickly by "link down". 
  2. Journalctl for Real-Time Logs:
    journalctl -u NetworkManager -f (or -u systemd-networkd if using that).
    Tail with -f to watch live. Flapping shows rapid state changes.
  3. Ethtool for Stats:
    ethtool -S enp0s3 (your interface).
    Look for high "rx_errors", "tx_errors", or "carrier_changes" – big numbers mean flapping. 
  4. IP Link Monitor:
    ip monitor link – Watches for state flips in real time.

If you see patterns like "link up/down" every 10-60 seconds, congrats – it's flapping!

 

Step 2: Fix the Flapping

Start simple and escalate. Restart services/interfaces as needed: systemctl restart NetworkManager or ip link set enp0s3 down/up.

  1. Update Drivers/Firmware:
    • apt update && apt upgrade (Ubuntu) or yum update (CentOS).
    • For specific cards (e.g., QLogic): Install latest from vendor (e.g., modprobe qlge).
    • Reboot: reboot.
  2. Disable Power Saving:
    • Edit /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf: Set wifi.powersave = 2 (off).
    • Or PCIE ASPM: echo "performance" > /sys/module/pcie_aspm/parameters/policy.
    • Make permanent: Add to /etc/sysctl.conf or GRUB (pcie_aspm=off). 
  3. Bonding/Team Fixes:
    • Check status: cat /proc/net/bonding/bond0.
    • Ensure slaves match speed/duplex: ethtool enp0s3 | grep Speed.
    • Reconfigure if mismatched. 
  4. Switch-Side Tweaks:
    • Disable STP on port if looping
    • Check for MAC flaps: Clear ARP cache or set static MAC. 

Tip: Sometimes manually configuring the network can stop flapping.

Test post-fix: Ping a stable host (ping 8.8.8.8) and watch for drops.

 

Troubleshooting Table: Still Flapping? 

Symptom Likely Cause Quick Fix
Random drops Auto config is failing Set static network information
Driver errors in dmesg Outdated firmware Update kernel/modules - modinfo qlge for QLogic.
ASPM in logs Power mgmt Disable in BIOS or sysctl as above
Bond slave mismatch Config error Align speeds: ethtool -s enp0s3 speed 1000 duplex full

 

Bonus: Prevent Future Flaps

  • Monitor with tools like Nagios/Zabbix – alert on state changes. 
  • Schedule checks: Cron dmesg | grep link > /var/log/flap.log.
  • If on our VPS, Nebula Core console helps debug remotely.

 

Quick Recap (Cheat Sheet) 

Step Action
1 Logs: `dmesg
2 Check configs
3 Update: apt update && apt upgrade or dnf update
4 Power off: Edit sysctl/PCIE params
5 Test: Ping + monitor

 

Need Help? 

  • Logs got you stumped? Screenshot and contact us

 


Flap fixed! Stable links mean happy servers – game on or host away.

Was this answer helpful?

Related Articles

Installing a Custom ISO on Your VPS

Got a specific OS or distro in mind that's not in our default list? No sweat! Nebula Core lets...

What to Do After Ordering Your VPS (Setup Guide)

Just ordered a VPS with us? Hell yeah – welcome to the big leagues! Whether you're setting up a...

Powered by WHMCompleteSolution