# Cockpit: "Cannot refresh cache whilst offline" / PackageKit + NetworkManager Fix

## Symptom

Cockpit's **Updates** page shows:
> Loading available updates failed — Cannot refresh cache whilst offline

Yet the system has full internet connectivity — `ping`, `curl`, and `apt update` all work.

## Root Cause

On Ubuntu Server, **`systemd-networkd`** handles networking, but **PackageKit** (Cockpit's backend for the updates page) checks **NetworkManager's** D-Bus state to determine if the system is online.

When NM is installed but has **no connection profile** configured (because systemd-networkd is doing the actual networking), NM reports:
```
STATE: disconnected  CONNECTIVITY: none
```

PackageKit sees this and refuses to refresh the cache — even though the interface is up and routable via systemd-networkd.

## Diagnosis

```bash
# NM says disconnected even though networking works
nmcli general status
# → STATE: disconnected  CONNECTIVITY: none

# But systemd-networkd is fine
networkctl status
# → State: routable
# → Online state: partial

# PackageKit confirms it thinks we're offline
busctl get-property org.freedesktop.PackageKit /org/freedesktop/PackageKit org.freedesktop.PackageKit NetworkState
# 0 = Offline, 1 = Limited, 2 = Online
```

## Fix

Since systemd-networkd is doing all the networking, NetworkManager is redundant. Stop and mask it:

```bash
sudo systemctl mask NetworkManager --now
```

Then restart PackageKit so it re-checks the network state without NM:

```bash
sudo systemctl restart packagekit
sleep 2
busctl get-property org.freedesktop.PackageKit /org/freedesktop/PackageKit org.freedesktop.PackageKit NetworkState
# → u 2  (Online)
```

After this, reload Cockpit's updates page — it should work.

## Verification

```bash
# PackageKit should now report Online
busctl get-property org.freedesktop.PackageKit /org/freedesktop/PackageKit org.freedesktop.PackageKit NetworkState
# Expected: u 2

# Confirm networking still works
ping -c 1 8.8.8.8
curl -s --max-time 5 https://google.com -o /dev/null -w "%{http_code}"
```

## Why This Happens

Ubuntu Server 24+ ships with **both** `systemd-networkd` and `NetworkManager` installed. The server installer configures networkd, not NM. But NM's service is still present and starts, sees no connections, and reports "offline." PackageKit only knows how to check NM — it has no fallback for systems that don't use NM.

Masking NM is safe and standard on systems where networkd handles all interfaces.
