cockpit-project / cockpit

Cockpit is a web-based graphical interface for servers.
http://www.cockpit-project.org/
GNU Lesser General Public License v2.1
10.93k stars 1.09k forks source link

Ubuntu: packagekit cannot refresh cache whilst offline #8477

Closed skluthe closed 6 years ago

skluthe commented 6 years ago

In the web interface when trying to check for updates I get "Cannot refresh cache whilst offline" meanwhile when I ssh into the machine I can run pkcon get-updates and it will show an update available.

This machine is running a reverse proxy and I can let you login to take a look. This happens on almost every 16.04 machine I have. Please let me know if you have any other information.


As a workaround you can create any NetworkManager connection, like this one:

 nmcli con add type dummy con-name fake ifname fake0 ip4 1.2.3.4/24 gw4 1.2.3.1
skluthe commented 6 years ago

Added another network interface and enabled it via network-manager and it's now working.

martinpitt commented 6 years ago

This is a known limitation with Ubuntu16.04's NetworkManager. If it is installed, it needs to manage at least one interface, otherwise it reports to the system that it's "offline". PackageKit queries this. This got fixed in later Ubuntu releases. There's not much we can do on the Cockpit side, I'm afraid.

greenpoise commented 5 years ago

I am running a clean 19.04 installation and I am getting this error. Cant find too much information about how to fix it. Last resort, post here and see if there is a solution. Otherwise on to the next one.

martinpitt commented 5 years ago

@greenpoise: I noticed that as well, I had to reintroduce the test workaround in commit ab3740dfd3202846. I'm afraid I don't know a better workaround there either. Supposedly in your installation you have NetworkManager running, but it's not actually managing anything? (nmcli d) In a server install, Ubuntu uses networkd by default (via netplan).

ipl-adm commented 5 years ago

Had same error on clean debian9. In Applications was an error "Cannot refresh cache whilst offline".

ipl-adm commented 5 years ago

There is my settings for network-interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug ens18
iface ens18 inet static
        address 194.147.35.237/24
        gateway 194.147.35.1
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 77.88.8.8
        dns-search kvm.u30051
mxwlsavard commented 5 years ago

I'm running Ubuntu 19.04 server and not using Network Manager (as confirmed by running nmcli d):

$ nmcli d
DEVICE           TYPE       STATE         CONNECTION
wlx0007324c2ce7  wifi       disconnected  --
enp1s0           ethernet   unmanaged     --
lo               loopback   unmanaged     --
wg0              wireguard  unmanaged     --

so I just stopped Network Manager (sudo systemctl stop NetworkManager.service) and everything appears to be working still so I disabled it from starting again (sudo systemctl disable NetworkManager.service) and now I can check for updates in Cockpit!

ghost commented 4 years ago

(sudo systemctl stop NetworkManager.service) and everything appears to be working still so I disabled it from starting again (sudo systemctl disable NetworkManager.service) and now I can check for updates in Discover (Debian Linux) too!

fersalme commented 4 years ago

Hi, I did have the same problem on ubuntu 16.04.5 LTS and the message "offline errors when no using NetworkManager" from PackageKit. I saw the same problem on this post http://nicolasjolet.blogspot.com/2017/02/resolve-cannot-download-packages-whilst.html. So, I edited /etc/NetworkManager/NetworkManager.conf, on only this part [ifupdown] managed=false and I changed for [ifupdown] managed=true and restarted the service with sudo service NetworkManager restart. I fixed the problem and now I can check for updates!

cinderblock commented 4 years ago

EDIT: Note: This issue is a top hit for certain error strings that come up in more recent versions of Ubuntu. Just wanted to add some tips for future people that come across this.

Neither stopping NetworkManager nor setting managed=true (and restarting) worked for me with a very fresh install of Ubuntu 19.10.

I had to disable NetworkManager and do a full restart.


Update: Trying again, all it took was:

sudo systemctl disable network-manager.service
sudo systemctl stop network-manager.service

Update again:

It was some combination of disabling/stopping network-manager.service that made it work. I've had it where two simple commands worked. I've had it where I had to do a restart too.

leedickey commented 4 years ago

This seems to have returned for Ubuntu 20.04.

edherpaulinelli commented 4 years ago

This procedure worked very well on my Debian Buster - 10.3.

ICarryTheDustOfAJourney commented 4 years ago

After stopping network-manager, the network-tab in Cockpit remains blank. After sudo service network-manager start, the network-tab comes back but updates aren't working.

Stopping network-manager is not really a good solution here (Ubuntu Server 20.04)

khushil commented 4 years ago

On 19.10 this doesn't resolve the problem...

sudo systemctl disable network-manager.service
sudo systemctl stop network-manager.service
Cu64 commented 4 years ago

I'm on Ubuntu Server 20.04. Stopping and disabling NetworkManager then reboot worked for me.

HyderKhalil commented 4 years ago

Also experiencing this error message on Ubuntu Server 20.04

UnixNight commented 4 years ago

Still happening on Ubuntu Server 20.04 although I do see my ethernet adapter as an unmanaged interface

HyderKhalil commented 4 years ago

I'm on Ubuntu Server 20.04. Stopping and disabling NetworkManager then reboot worked for me.

Worked for me too on 20.04 and Cockpit 215.

bootrec commented 4 years ago

I'm on Ubuntu Server 20.04. Stopping and disabling NetworkManager then reboot worked for me.

Worked for me too on 20.04 and Cockpit 215.

Confirmed for me as well.

cinderblock commented 4 years ago

Want to say "me too"? Great! Just click the 👍

Only 👉you👈 can prevent clutter fires in GitHub issue comments.

Libitum commented 4 years ago

Finally I found the solution for Ubuntu 20.04. Yes "systemctl disable network-manager.service" works for this issue, but would cause the problem of Networking tab empty #14023 . The root cause is that systemd-networkd is used by default instead of NetworkManager in Ubuntu 20.04 server. If we disable NM, the Networking tab would be empty; If we enable NM, "Cannot refresh cache whilst offline" would occur because NM actually managed nothing. So the best solution is that use NM instead of systemd-networkd:

# Change netplan config to use NM instead
# File path: /etc/netplan/50-cloud-init.yaml
network:
    version: 2
    renderer: NetworkManager    # This is the changed line. Default is networkd
    ethernets:
        eno1:      # This is different by hardware.
            dhcp4: true

# Then apply it
sudo netplan try   # This will disable systemd-networkd and enable network-manager.service

Then everything works.

UnixNight commented 4 years ago

Finally I found the solution for Ubuntu 20.04. Yes "systemctl disable network-manager.service" works for this issue, but would cause the problem of Networking tab empty #14023 . The root cause is that systemd-networkd is used by default instead of NetworkManager in Ubuntu 20.04 server. If we disable NM, the Networking tab would be empty; If we enable NM, "Cannot refresh cache whilst offline" would occur because NM actually managed nothing. So the best solution is that use NM instead of systemd-networkd:

# Change netplan config to use NM instead
# File path: /etc/netplan/50-cloud-init.yaml
network:
    version: 2
    renderer: NetworkManager    # This is the changed line. Default is networkd
    ethernets:
        eno1:      # This is different by hardware.
            dhcp4: true

# Then apply it
sudo netplan try   # This will disable systemd-networkd and enable network-manager.service

Then everything works.

I've done this change and now on reboot of my server, I no longer have networking unless I manually go in and sudo netplan try

Is there another step after to permanently commit the changes?

Libitum commented 4 years ago

@UnixNight Just try this:

systemctl enable network-manager.service
systemctl disable systemd-networkd.service
Th3Whit3Wolf commented 4 years ago

Guys I think this should have a wiki page or be displayed in a FAQ or something. IDK what percentage of cockpit users run Ubuntu but I feel like it has be a non insignificant amount and digging through github issues to find the solution to a common problem isn't a great user experience.

martinpitt commented 4 years ago

I sympathize, but there really isn't much that cockpit can do here -- this needs to be fixed in Ubuntu's packagekit or possibly glib2, to get along with the default network configuration with netplan.

martinpitt commented 4 years ago

I added a workaround into the issue description which is reasonably unintrusive and avoids changing networking backends.

skewty commented 4 years ago

Collecting all the best information above into a single post we get:

Instruction from Fresh Install

After installation using ubuntu-20.04-live-server.iso file completes and you reboot:

  1. sudo apt install network-manager
  2. sudo nano /etc/netplan/00-installer-config.yaml
    • and at same indent level as version: 2 on a new line insert renderer: NetworkManager
  3. sudo systemctl enable network-manager.service
  4. sudo systemctl disable systemd-networkd.service
dbkinghorn commented 4 years ago

Here's a script for using netplan to change Ubuntu20.04 server from networkd to NetworkManager on all interfaces (run with sudo) ... should work on other Ubuntu releases using netplan too.

https://gist.github.com/dbkinghorn/ed923bbcb7ec3f53bd2da5fe5e9b49b2

quantuumsnot commented 4 years ago

I'm also confirming that stopping and disabling NetworkManager.service fixes the issue but gives empty Networking tab Ubuntu Server 20.04 x64 Dell Inspiron N5110

Libitum commented 4 years ago

@quantuumsnot You can just try the solution above. Using network-manager instead of systemd-networkd makes everything works.

quantuumsnot commented 4 years ago

@quantuumsnot You can just try the solution above. Using network-manager instead of systemd-networkd makes everything works.

Yeah, already used the solution but the problem started from the point where Ubuntu decided to reject the settings for getting internet access. That's why I was pushed to manually add nameservers addresses which is a somewhat buggy workaround because after each restart the machine still has no domain name resolving

TriMoon commented 4 years ago

Please bear in mind that NetworkManager.service is the proper name of the service. Also please see this info. :wink: Linux systems are all heading towards using systemd as system manager instead of SysV etc, so don't disable systemd-networkd.service :tongue:

I personally only have NetworkManager running at moment for the WiFi interface on a desktop, and use systemd-networkd for configuring the ethernet port(s)...

quantuumsnot commented 3 years ago

I personally only have NetworkManager running at moment for the WiFi interface on a desktop, and use systemd-networkd for configuring the ethernet port(s)...

Can you post here the contents (remove public IPs) of the following files in your system: /etc/network/interfaces /etc/netplan/00-installer-config.yaml

danielbostock commented 3 years ago

Finally I found the solution for Ubuntu 20.04. Yes "systemctl disable network-manager.service" works for this issue, but would cause the problem of Networking tab empty #14023 . The root cause is that systemd-networkd is used by default instead of NetworkManager in Ubuntu 20.04 server. If we disable NM, the Networking tab would be empty; If we enable NM, "Cannot refresh cache whilst offline" would occur because NM actually managed nothing. So the best solution is that use NM instead of systemd-networkd:

# Change netplan config to use NM instead
# File path: /etc/netplan/50-cloud-init.yaml
network:
    version: 2
    renderer: NetworkManager    # This is the changed line. Default is networkd
    ethernets:
        eno1:      # This is different by hardware.
            dhcp4: true

# Then apply it
sudo netplan try   # This will disable systemd-networkd and enable network-manager.service

Then everything works.

I can confirm this worked for me as well with Ubuntu 20.04.

Thanks for the fix!

fenland787 commented 3 years ago

`

Finally I found the solution for Ubuntu 20.04.
Yes "systemctl disable network-manager.service" works for this issue, but would cause the problem of Networking tab empty #14023 .
The root cause is that systemd-networkd is used by default instead of NetworkManager in Ubuntu 20.04 server. If we disable NM, the Networking tab would be empty; If we enable NM, "Cannot refresh cache whilst offline" would occur because NM actually managed nothing. So the best solution is that use NM instead of systemd-networkd:

# Change netplan config to use NM instead
# File path: /etc/netplan/50-cloud-init.yaml
network:
    version: 2
    renderer: NetworkManager    # This is the changed line. Default is networkd
    ethernets:
        eno1:      # This is different by hardware.
            dhcp4: true

# Then apply it
sudo netplan try   # This will disable systemd-networkd and enable network-manager.service

Then everything works.

` Yes, I'm a beginner but this worked fine for me on both 'server' and 'desktop' installs of Ubuntu 20.04. Executed as 'root' (remember to 'accept' netplan try!) and then survives reboot. Many thanks for the fix.

quantuumsnot commented 3 years ago
  1. sudo systemctl enable network-manager.service
  2. sudo systemctl disable systemd-networkd.service

If you have Wireguard, after doing those commands you can forget it to work again (including accessing Cockpit through the Wireguard) You must do the following if you want Wireguard VPN be usable again:

systemctl stop wg-quick@wg0
systemctl start wg-quick@wg0
0x20Fearless commented 3 years ago

Doing sudo snap install network-manager on a fresh 20.04.1 fixed it for me, no file edits, survives after a reboot.

Tuliku commented 3 years ago

Doing sudo snap install network-manager on a fresh 20.04.1 fixed it for me, no file edits, survives after a reboot.

I've tried this as well on my fresh 20.04.1 ubuntu server installation, but it fails to start up, even a manual restart did nothing. After uninstalling sudo snap install network-manager and a reboot, everything works fine now without any other fixes.

ipimpat commented 3 years ago

Finally I found the solution for Ubuntu 20.04. Yes "systemctl disable network-manager.service" works for this issue, but would cause the problem of Networking tab empty #14023 . The root cause is that systemd-networkd is used by default instead of NetworkManager in Ubuntu 20.04 server. If we disable NM, the Networking tab would be empty; If we enable NM, "Cannot refresh cache whilst offline" would occur because NM actually managed nothing. So the best solution is that use NM instead of systemd-networkd:

# Change netplan config to use NM instead
# File path: /etc/netplan/50-cloud-init.yaml
network:
    version: 2
    renderer: NetworkManager    # This is the changed line. Default is networkd
    ethernets:
        eno1:      # This is different by hardware.
            dhcp4: true

# Then apply it
sudo netplan try   # This will disable systemd-networkd and enable network-manager.service

Then everything works.

Worked for me too, but when switching to NetworkManager as renderer I also had to configure NetworkManager to use dhclient, otherwise my DHCP server would not offer the same IP, but a new one, resulting in the connection getting lost.

sudo tee /etc/NetworkManager/conf.d/dhcp.conf <<EOT
[main]
dhcp=dhclient
EOT
Devnol commented 3 years ago

Had same issue in Ubuntu server 20.10 (arm64 on a Pi4 Model B), can confirm that it works there too.

michaelomm commented 3 years ago

Doing sudo snap install network-manager on a fresh 20.04.1 fixed it for me, no file edits, survives after a reboot.

I've tried this as well on my fresh 20.04.1 ubuntu server installation, but it fails to start up, even a manual restart did nothing. After uninstalling sudo snap install network-manager and a reboot, everything works fine now without any other fixes.

This worked for me

sudo snap install network-manager && sudo snap remove network-manager && sudo shutdown -r now

knfarhan commented 3 years ago

Doing sudo snap install network-manager on a fresh 20.04.1 fixed it for me, no file edits, survives after a reboot.

I've tried this as well on my fresh 20.04.1 ubuntu server installation, but it fails to start up, even a manual restart did nothing. After uninstalling sudo snap install network-manager and a reboot, everything works fine now without any other fixes.

This worked for me

sudo snap install network-manager && sudo snap remove network-manager && sudo shutdown -r now

i confirm this resolved my issue as well, now my NC is up to date :)

Ainz commented 3 years ago

Just installed a few moments ago and stumbled over this and reviewing a few of above solutions.

Went for sudo snap install network-manager && sudo snap remove network-manager && sudo shutdown -r now since it seems the simplest copy-paste for a Linux Ubuntu aficionado and CLI hater like me.

That gave errors reading repos... dont know if temporary but i'll wait a bit and reboot and get back.

E: http://se.archive.ubuntu.com/ubuntu focal-updates InRelease is not (yet) available (Temporary failure resolving 'se.archive.ubuntu.com') E: http://se.archive.ubuntu.com/ubuntu focal-backports InRelease is not (yet) available (Temporary failure resolving 'se.archive.ubuntu.com') E: http://se.archive.ubuntu.com/ubuntu focal-security InRelease is not (yet) available (Temporary failure resolving 'se.archive.ubuntu.com')

It also switched the NIC order around, got two...

michaelomm commented 3 years ago

E: http://se.archive.ubuntu.com/ubuntu focal-updates InRelease is not (yet) available (Temporary f**ailure resolving 'se.archive.ubuntu.com'**) E: http://se.archive.ubuntu.com/ubuntu focal-backports InRelease is not (yet) available (Temporary **failure resolving 'se.archive.ubuntu.com'**) E: http://se.archive.ubuntu.com/ubuntu focal-security InRelease is not (yet) available (Temporary **failure resolving 'se.archive.ubuntu.com'**)

It also switched the NIC order around, got two...

Is this happenening on a fresh install? after sudo apt update && sudo apt upgrade -y && sudo shutdown -r now

honestly it just looks like your network connectiveity was broken before you ran those commands?

Ainz commented 3 years ago

Actually I started over and did not install Cockpit again so kinda workaround but not really.

But, yes it was on fresh install but I am not repeating that install sequence. So moot...

martinholovsky commented 3 years ago

Same issue on fresh Ubuntu 21.04

trallnag commented 3 years ago

The issue description now recommends to create a dummy connection with:

 nmcli con add type dummy con-name fake ifname fake0 ip4 1.2.3.4/24 gw4 1.2.3.1

But even after restarting Cockpit with sudo systemctl restart cockpit it does not work. Also tried to restart the http service directly, but to no avail. Is a reboot of the host required?


So a restart of my server did not help... The fake connection is definitely there.

image


I removed networkmanager

AudunVN commented 3 years ago

For those who are having trouble permanently resolving this when using Cockpit on Ubuntu 20.04 with cloud-init installed (like on a DigitalOcean droplet in my case): Create a new config file that loads before /etc/netplan/50-cloud-init.yaml such as /etc/netplan/49-set-nm-renderer-for-cockpit.yaml containing

# Set netplan renderer to NetworkManager, required for Cockpit to work
network:
  version: 2
  renderer: NetworkManager

and apply it using sudo netplan apply. You may need to restart the Cockpit service using sudo systemctl restart cockpit or similar depending on your setup.

Be careful with applying this if a different default renderer has been specified in your hosting provider's netplan config file, as other services may depend on that specific renderer.

MBeggiato commented 3 years ago

For those who are having trouble permanently resolving this when using Cockpit on Ubuntu 20.04 with cloud-init installed (like on a DigitalOcean droplet in my case): Create a new config file that loads before /etc/netplan/50-cloud-init.yaml such as /etc/netplan/49-set-nm-renderer-for-cockpit.yaml containing

# Set netplan renderer to NetworkManager, required for Cockpit to work
network:
  version: 2
  renderer: NetworkManager

and apply it using sudo netplan apply. You may need to restart the Cockpit service using sudo systemctl restart cockpit or similar depending on your setup.

Be careful with applying this if a different default renderer has been specified in your hosting provider's netplan config file, as other services may depend on that specific renderer.

Thank you so much! That works like a charm!

haneef95 commented 3 years ago

For those who are having trouble permanently resolving this when using Cockpit on Ubuntu 20.04 with cloud-init installed (like on a DigitalOcean droplet in my case): Create a new config file that loads before /etc/netplan/50-cloud-init.yaml such as /etc/netplan/49-set-nm-renderer-for-cockpit.yaml containing

# Set netplan renderer to NetworkManager, required for Cockpit to work
network:
  version: 2
  renderer: NetworkManager

and apply it using sudo netplan apply. You may need to restart the Cockpit service using sudo systemctl restart cockpit or similar depending on your setup.

Be careful with applying this if a different default renderer has been specified in your hosting provider's netplan config file, as other services may depend on that specific renderer.

Thanks that worked very well. Though, cautious me did: sudo netplan try and then applied once I confirmed it was working.

Though my wget still doesn't work, I'm not sure if it's a related issue.