WiFi connection keeps disconnecting Ubuntu 20.04

My internet connection keeps disconnecting for a random period of time and then reconnects. Sometimes it even disconnects and reconnects for 5-10 minutes straight. I have no idea what might be the issue I tried reinstalling the network manager but I couldn't resolve the issue.

Here are some logs from the network-manager service:

<info>  [1632573472.6381] device (wlo1): supplicant interface state: associated -> 4-way handshake
<info>  [1632573472.6554] device (wlo1): supplicant interface state: 4-way handshake -> completed
<warn>  [1632573513.4970] sup-iface[0x55fc01265100,wlo1]: connection disconnected (reason -4)
<info>  [1632573513.5222] device (wlo1): supplicant interface state: completed -> disconnected
<info>  [1632573514.1056] device (wlo1): supplicant interface state: disconnected -> scanning
<info>  [1632573518.6169] device (wlo1): supplicant interface state: scanning -> authenticating
<info>  [1632573518.6272] device (wlo1): supplicant interface state: authenticating -> associating
<info>  [1632573518.6315] device (wlo1): supplicant interface state: associating -> associated
<info>  [1632573518.6374] device (wlo1): supplicant interface state: associated -> 4-way handshake
<info>  [1632573518.6457] device (wlo1): supplicant interface state: 4-way handshake -> completed

uname

$ uname -a
Linux bojan-HP-250-G7-Notebook-PC 5.11.0-34-generic #36~20.04.1-Ubuntu SMP Fri Aug 27 08:06:32 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

lshw

$ sudo lshw -class network
  *-network                 
       description: Ethernet interface
       product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:01:00.0
       logical name: eno1
       version: 15
       serial: e8:d8:d1:32:05:d5
       capacity: 1Gbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress msix bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=5.11.0-34-generic firmware=rtl8168h-2_0.0.2 02/26/15 latency=0 link=no multicast=yes port=twisted pair
       resources: irq:16 ioport:4000(size=256) memory:b1104000-b1104fff memory:b1100000-b1103fff
  *-network
       description: Wireless interface
       product: RTL8821CE 802.11ac PCIe Wireless Network Adapter
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:02:00.0
       logical name: wlo1
       version: 00
       serial: c0:e4:34:73:1f:21
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless
       configuration: broadcast=yes driver=rtw_8821ce driverversion=5.11.0-34-generic firmware=N/A ip=192.168.100.73 latency=0 link=yes multicast=yes wireless=IEEE 802.11
       resources: irq:129 ioport:3000(size=256) memory:b1000000-b100ffff
  *-network:0
       description: Ethernet interface
       physical id: 3
       logical name: vethf0e7b23
       serial: de:97:8e:dc:a2:da
       size: 10Gbit/s
       capabilities: ethernet physical
       configuration: autonegotiation=off broadcast=yes driver=veth driverversion=1.0 duplex=full link=yes multicast=yes port=twisted pair speed=10Gbit/s
  *-network:1
       description: Ethernet interface
       physical id: 4
       logical name: vethed7164b
       serial: 4e:68:b7:51:6a:bd
       size: 10Gbit/s
       capabilities: ethernet physical
       configuration: autonegotiation=off broadcast=yes driver=veth driverversion=1.0 duplex=full link=yes multicast=yes port=twisted pair speed=10Gbit/s

modinfo

$ modinfo rtl8723be
filename:       /lib/modules/5.11.0-34-generic/kernel/drivers/net/wireless/realtek/rtlwifi/rtl8723be/rtl8723be.ko
firmware:       rtlwifi/rtl8723befw_36.bin
firmware:       rtlwifi/rtl8723befw.bin
description:    Realtek 8723BE 802.11n PCI wireless
license:        GPL
author:         Realtek WlanFAE <[email protected]>
author:         PageHe  <[email protected]>
srcversion:     17AE822AE3E2EAA1A500831
alias:          pci:v000010ECd0000B723sv*sd*bc*sc*i*
depends:        rtlwifi,rtl8723-common,rtl_pci,btcoexist,mac80211
retpoline:      Y
intree:         Y
name:           rtl8723be
vermagic:       5.11.0-34-generic SMP mod_unload modversions 
sig_id:         PKCS#7
signer:         Build time autogenerated kernel key
sig_key:        3F:78:34:4A:10:B7:65:C2:C5:FF:66:4E:89:21:35:FA:74:C9:00:B5
sig_hashalgo:   sha512
signature:      7E:E7:04:AA:0E:EC:DE:B0:6F:56:12:5A:7C:3E:7D:A0:98:4E:BB:3A:
        32:A2:24:BE:59:53:2F:E8:1B:E4:3E:63:57:FF:50:C4:E8:81:86:BE:
        72:3A:CD:49:9A:18:48:CB:0F:29:B9:22:F1:14:F2:4B:47:A8:E2:58:
        77:79:4C:CF:0F:FB:DA:9A:F9:C3:94:5E:A2:AF:EA:82:68:77:E8:66:
        1B:0A:D0:41:EE:E8:3A:B8:F5:B9:C7:B9:17:61:BE:50:9D:D8:0E:30:
        1E:9E:64:75:53:E9:C3:CB:E4:BE:0B:36:09:07:87:BF:C3:CF:83:ED:
        9D:F6:39:C2:6D:7F:35:EC:8B:B2:BC:C6:6E:EB:F2:9C:1B:99:53:5B:
        57:12:B6:AF:80:D3:BF:F3:CF:94:9B:6F:8E:E7:CD:6A:08:48:FC:83:
        69:EF:A7:AC:CC:4F:58:ED:C9:DC:E1:E6:E7:54:00:C5:1D:F9:5F:91:
        7D:93:C4:6A:66:DC:A1:F3:B3:30:0E:13:DF:2B:AD:5F:5A:70:C1:7A:
        0A:1C:63:22:D7:BA:95:13:DC:A3:30:13:C7:97:3E:CE:1C:BA:4F:AC:
        E2:F8:4E:6A:00:F0:69:8E:92:85:40:C1:55:10:37:CD:69:4E:42:ED:
        CC:48:E3:A5:10:C4:C6:20:51:5B:FE:17:E4:18:8D:D0:A7:43:44:B1:
        48:19:5B:F3:67:8E:94:81:CE:40:C2:DD:E5:B2:89:D3:01:DF:7C:21:
        98:91:21:BA:2D:F1:50:F7:DF:86:23:31:A8:22:33:87:C7:8C:95:5A:
        22:CB:56:E4:1C:60:83:E9:19:56:5E:24:46:E7:75:7E:46:FD:A9:8C:
        DA:02:26:C5:16:2D:D9:58:F9:D7:92:12:11:8E:CF:14:53:1B:3A:4A:
        F3:E6:32:F2:B2:47:08:34:C8:4A:5E:56:C5:12:BD:92:D1:A6:09:15:
        37:07:6D:69:49:A3:6D:8B:3F:30:C7:33:3B:69:AD:98:75:D3:17:2C:
        18:B5:0B:2F:6A:73:94:83:E0:A3:C8:BA:83:63:36:B1:CE:2B:48:B8:
        7B:A4:6D:BF:C3:53:80:25:4E:B0:8A:BC:04:0D:FB:49:B7:3F:B5:10:
        EF:FC:9D:2B:35:AE:73:24:ED:57:18:AE:29:49:48:92:DB:4F:04:D9:
        3B:D5:D2:81:80:48:5E:CE:9C:D1:FA:1E:4B:36:0D:E6:83:EB:FB:45:
        DD:EC:D1:8D:66:B2:48:8D:E4:65:D2:F2:D3:82:B0:22:D4:5D:D3:C8:
        22:17:A9:AB:A6:70:09:5F:44:CC:A3:C4:90:85:9C:3E:F8:9A:45:8A:
        89:0A:E1:47:88:66:39:E9:AF:9A:F1:AA
parm:           swenc:Set to 1 for software crypto (default 0)
 (bool)
parm:           ips:Set to 0 to not use link power save (default 1)
 (bool)
parm:           swlps:Set to 1 to use SW control power save (default 0)
 (bool)
parm:           fwlps:Set to 1 to use FW control power save (default 1)
 (bool)
parm:           msi:Set to 1 to use MSI interrupts mode (default 0)
 (bool)
parm:           aspm:Set to 1 to enable ASPM (default 1)
 (int)
parm:           debug_level:Set debug level (0-5) (default 0) (int)
parm:           debug_mask:Set debug mask (default 0) (ullong)
parm:           disable_watchdog:Set to 1 to disable the watchdog (default 0)
 (bool)
parm:           ant_sel:Set to 1 or 2 to force antenna number (default 0)
 (int)

ls

ls -al /etc/pm/config.d/
ls: cannot access '/etc/pm/config.d/': No such file or directory
sudo ls -al /etc/pm/config.d/
ls: cannot access '/etc/pm/config.d/': No such file or directory

ls

$ ls -al /etc/modprobe.d/
total 68
drwxr-xr-x   2 root root  4096 јул 31 08:54 .
drwxr-xr-x 149 root root 12288 сеп 24 17:19 ..
-rw-r--r--   1 root root  2507 јул 31  2015 alsa-base.conf
-rw-r--r--   1 root root   154 фев 16  2020 amd64-microcode-blacklist.conf
-rw-r--r--   1 root root   325 мар 12  2020 blacklist-ath_pci.conf
-rw-r--r--   1 root root  1518 јан 17  2021 blacklist.conf
-rw-r--r--   1 root root   210 мар 12  2020 blacklist-firewire.conf
-rw-r--r--   1 root root   677 мар 12  2020 blacklist-framebuffer.conf
-rw-r--r--   1 root root   156 јул 31  2015 blacklist-modem.conf
lrwxrwxrwx   1 root root    41 јун  3  2020 blacklist-oss.conf -> /lib/linux-sound-base/noOSS.modprobe.conf
-rw-r--r--   1 root root   583 мар 12  2020 blacklist-rare-network.conf
-rw-r--r--   1 root root   264 апр 13  2020 broadcom-sta-common.conf
-rw-r--r--   1 root root   180 апр 13  2020 broadcom-sta-dkms.conf
-rw-r--r--   1 root root   127 јан 22  2020 dkms.conf
-rw-r--r--   1 root root   154 фев 12  2020 intel-microcode-blacklist.conf
-rw-r--r--   1 root root   347 мар 12  2020 iwlwifi.conf

iwlist

sudo iwlist freq
lo        no frequency information.

eno1      no frequency information.

wlo1      26 channels in total; available frequencies :
          Channel 01 : 2.412 GHz
          Channel 02 : 2.417 GHz
          Channel 03 : 2.422 GHz
          Channel 04 : 2.427 GHz
          Channel 05 : 2.432 GHz
          Channel 06 : 2.437 GHz
          Channel 07 : 2.442 GHz
          Channel 08 : 2.447 GHz
          Channel 09 : 2.452 GHz
          Channel 10 : 2.457 GHz
          Channel 11 : 2.462 GHz
          Channel 12 : 2.467 GHz
          Channel 13 : 2.472 GHz
          Channel 36 : 5.18 GHz
          Channel 40 : 5.2 GHz
          Channel 44 : 5.22 GHz
          Channel 48 : 5.24 GHz
          Channel 52 : 5.26 GHz
          Channel 56 : 5.28 GHz
          Channel 60 : 5.3 GHz
          Channel 64 : 5.32 GHz
          Channel 149 : 5.745 GHz
          Channel 153 : 5.765 GHz
          Channel 157 : 5.785 GHz
          Channel 161 : 5.805 GHz
          Channel 165 : 5.825 GHz
          Current Frequency=2.457 GHz (Channel 10)

br-ec141e7941cd  no frequency information.

br-f93fc947e076  no frequency information.

br-080efbda3d64  no frequency information.

br-1110f8e908c5  no frequency information.

br-6e3cb22ca843  no frequency information.

br-d3126a6e15ac  no frequency information.

docker0   no frequency information.

br-46b9b7a049c8  no frequency information.

br-6390def20095  no frequency information.

vethf0e7b23  no frequency information.

vethed7164b  no frequency information.

lspci

lspci -knn | grep Net -A2
02:00.0 Network controller [0280]: Realtek Semiconductor Co., Ltd. RTL8821CE 802.11ac PCIe Wireless Network Adapter [10ec:c821]
    DeviceName: WLAN
    Subsystem: Hewlett-Packard Company RTL8821CE 802.11ac PCIe Wireless Network Adapter [103c:831a]
    Kernel driver in use: rtw_8821ce
    Kernel modules: rtw88_8821ce

lsmod

sudo lsmod | grep rtl8723be

iwconfig

sudo iwconfig
lo        no wireless extensions.

eno1      no wireless extensions.

wlo1      IEEE 802.11  ESSID:"marko"  
          Mode:Managed  Frequency:2.457 GHz  Access Point: F8:BF:09:85:63:68   
          Bit Rate=58.5 Mb/s   Tx-Power=20 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on
          Link Quality=70/70  Signal level=-36 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:7  Invalid misc:176   Missed beacon:0

br-ec141e7941cd  no wireless extensions.

br-f93fc947e076  no wireless extensions.

br-080efbda3d64  no wireless extensions.

br-1110f8e908c5  no wireless extensions.

br-6e3cb22ca843  no wireless extensions.

br-d3126a6e15ac  no wireless extensions.

docker0   no wireless extensions.

br-46b9b7a049c8  no wireless extensions.

br-6390def20095  no wireless extensions.

vethf0e7b23  no wireless extensions.

vethed7164b  no wireless extensions.

inxi

inxi -Fxz

Command 'inxi' not found, but can be installed with:

sudo apt install inxi

Fix

By adding the following drivers to the blacklist in /etc/modprobe.d/blacklist.conf and installing rtl8821ce I was able to fix the issue. Once I executed the commands I rebooted my laptop and the issue was resolved. Thanks for the help @sancho.sReinstateMonicaCellio.

sudo nano /etc/modprobe.d/blacklist.conf

blacklist 8821ce
blacklist rtw88
blacklist rtw88_8821ce
blacklist rtw88_8821c
blacklist rtw88_pci
blacklist rtw88_core

sudo apt-get install dkms build-essential rtl8821ce-dkms

Solution 1:

You have a Realtek RTL8821CE 802.11ac/abgn PCIe WLAN with Bluetooth 5.0 Single-Chip Controller, with driver rtw_8821ce. As mentioned in a comment, there is likely interference between bluetooth and wifi.

Please do the following to try solving the problem:

  1. Post the output of

     $ modinfo rtw_8821ce            <-- Replace the current posted modinfo
     $ ls -al /etc/pm/
     $ sudo lsmod | grep rtw_8821ce
    
  2. Post the exact brand/model of your PC.

  3. Be ready to perform your own web searches for information, and take time to try on your own.

You might need this solution.

Related:

  1. https://linux-hardware.org/index.php?id=pci:10ec-c821-17aa-c024
  2. https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1927808