{"id":2042,"date":"2023-01-31T21:36:10","date_gmt":"2023-01-31T21:36:10","guid":{"rendered":"https:\/\/linuxdigest.com\/?p=2042"},"modified":"2023-01-31T22:30:23","modified_gmt":"2023-01-31T22:30:23","slug":"linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution","status":"publish","type":"post","link":"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/","title":{"rendered":"Linux laptop wont connect to wifi after suspend? A quick and dirty solution."},"content":{"rendered":"\n<p>Recently I had this problem with my Lenovo laptop where it wouldn&#8217;t connect to wifi after it resumed from sleep. I&#8217;m sharing the quick and dirty hack to resolve the problem in the hopes it will help others to solve the same problem. It should also work for other laptops and wifi adapters.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Damn you Lenovo!<\/h2>\n\n\n\n<p>A few months back, I bought a shiny new laptop for my personal projects. I tried searching for laptops with decent value for money that were likely to have decent hardware support in Linux. <\/p>\n\n\n\n<p>I ended up buying the Lenovo L15. Not least because it was supposed to have Ubuntu certification. No store in my area had a laptop with Linux pre-installed in stock. And I didn&#8217;t want to wait for one to be shipped to me. So a Ubuntu certified laptop should enable me to just install Ubuntu and start working right away. Right?<\/p>\n\n\n\n<p>Well, it turns out Lenovo had replaced the intel wifi adapter, which was in the ubuntu certified version, with a Realtek one. Otherwise, all the specs were the same. <\/p>\n\n\n\n<p>This didn&#8217;t work out well for me since the included RTL8852AE adapter did not have working drivers in the latest ubuntu version. Although I did eventually manage to get it working. I&#8217;m not sure where I got newer drivers, but it was probably from lwfinger on GitHub. Which is incidentally the same place where I got the solution to the suspend problem from.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Authentication is required after resuming from suspend<\/h2>\n\n\n\n<p>Everything was working fine until I closed the lid and the laptop suspended. After resuming again Network Manager just asked me for my password again and again. The only way for me to connect to wifi again was to either reboot or disable and enable wifi several times.<\/p>\n\n\n\n<p>As far as I can tell, this is a bug in the Realtek driver. So all I could do was wait for a new release. So I endured for a while.<\/p>\n\n\n\n<p>Eventually, I did find a solution. I must confess, this was not my idea. I came across this while looking for newer drivers in <a href=\"https:\/\/github.com\/lwfinger\/rtw89\">this unofficial driver repo.<\/a><\/p>\n\n\n\n<p>Essentially we create a script that unloads the driver before the machine is suspended and then loads the driver fresh when it resumes. After I did this, there have been zero problems with wifi.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Find the name of your driver<\/h2>\n\n\n\n<p>In my case, the driver is from Realtek so I will look for kernel modules starting with &#8220;rt&#8221;. But this should work for other adapters with similar problems. Just substitute &#8220;rt&#8221; with what is appropriate.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ lsmod | grep rt\nrtw89_pci              49152  0\nrtw89_core           1003520  1 rtw89_pci\nmac80211             1249280  2 rtw89_core,rtw89_pci\ncfg80211              974848  2 rtw89_core,mac80211\nxt_addrtype            16384  2\n<\/pre>\n\n\n\n<p>In this case, the module is named rtw89_pci. Now we can move to the next step.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create the script<\/h2>\n\n\n\n<p>We need to create a script and place it in the correct directory, so Systemd will run it every time the laptop changes to or from suspend. The script should be located in<strong> \/usr\/lib\/systemd\/system-sleep\/<\/strong>. <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">vim  \/usr\/lib\/systemd\/system-sleep\/suspend_wifi<\/pre>\n\n\n\n<p>Place the following in your script and replace rtw89_pci with the module name you found in the last step.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/sh\nif [ \"${1}\" == \"pre\" ]; then\n  modprobe -rv rtw89_pci\nelif [ \"${1}\" == \"post\" ]; then\n  modprobe -v rtw89_pci\nfi\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Make the script executable<\/h2>\n\n\n\n<p>The last step should be to make sure your script is executable with chmod:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">chmod 755 \/usr\/lib\/systemd\/system-sleep\/suspend_wifi<\/pre>\n\n\n\n<p>And we are done! The next time the machine suspends it should unload the driver and load it again when it is turned back on.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I had this problem with my Lenovo laptop where it wouldn&#8217;t connect to wifi after&hellip;<\/p>\n","protected":false},"author":1,"featured_media":2052,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux laptop wont connect to wifi after suspend? A quick and dirty solution. - Linux Digest<\/title>\n<meta name=\"description\" content=\"Recently I had this problem with my Lenovo laptop where it wouldn&#039;t connect to wifi after it resumed from sleep. I&#039;m sharing the quick and dirty hack to resolve the problem in the hopes it will help others to solve the same problem.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux laptop wont connect to wifi after suspend? A quick and dirty solution. - Linux Digest\" \/>\n<meta property=\"og:description\" content=\"Recently I had this problem with my Lenovo laptop where it wouldn&#039;t connect to wifi after it resumed from sleep. I&#039;m sharing the quick and dirty hack to resolve the problem in the hopes it will help others to solve the same problem.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/\" \/>\n<meta property=\"og:site_name\" content=\"Linux Digest\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-31T21:36:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-31T22:30:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2023\/01\/no-wifi-2.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"740\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"The Linux Digest Guy\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"The Linux Digest Guy\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/\"},\"author\":{\"name\":\"The Linux Digest Guy\",\"@id\":\"https:\/\/linuxdigest.com\/#\/schema\/person\/29c97230aa94affab929a88c6a10adb2\"},\"headline\":\"Linux laptop wont connect to wifi after suspend? A quick and dirty solution.\",\"datePublished\":\"2023-01-31T21:36:10+00:00\",\"dateModified\":\"2023-01-31T22:30:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/\"},\"wordCount\":566,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/linuxdigest.com\/#organization\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/\",\"url\":\"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/\",\"name\":\"Linux laptop wont connect to wifi after suspend? A quick and dirty solution. - Linux Digest\",\"isPartOf\":{\"@id\":\"https:\/\/linuxdigest.com\/#website\"},\"datePublished\":\"2023-01-31T21:36:10+00:00\",\"dateModified\":\"2023-01-31T22:30:23+00:00\",\"description\":\"Recently I had this problem with my Lenovo laptop where it wouldn't connect to wifi after it resumed from sleep. I'm sharing the quick and dirty hack to resolve the problem in the hopes it will help others to solve the same problem.\",\"breadcrumb\":{\"@id\":\"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/linuxdigest.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux laptop wont connect to wifi after suspend? A quick and dirty solution.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/linuxdigest.com\/#website\",\"url\":\"https:\/\/linuxdigest.com\/\",\"name\":\"Linux Digest\",\"description\":\"Linux tutorials for everyone\",\"publisher\":{\"@id\":\"https:\/\/linuxdigest.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/linuxdigest.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/linuxdigest.com\/#organization\",\"name\":\"Linux Digest\",\"url\":\"https:\/\/linuxdigest.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/linuxdigest.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/logo1.png\",\"contentUrl\":\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/logo1.png\",\"width\":1102,\"height\":170,\"caption\":\"Linux Digest\"},\"image\":{\"@id\":\"https:\/\/linuxdigest.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/linuxdigest.com\/#\/schema\/person\/29c97230aa94affab929a88c6a10adb2\",\"name\":\"The Linux Digest Guy\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/linuxdigest.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ac6bcf745dec6961360ccf2d2711f26c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ac6bcf745dec6961360ccf2d2711f26c?s=96&d=mm&r=g\",\"caption\":\"The Linux Digest Guy\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Linux laptop wont connect to wifi after suspend? A quick and dirty solution. - Linux Digest","description":"Recently I had this problem with my Lenovo laptop where it wouldn't connect to wifi after it resumed from sleep. I'm sharing the quick and dirty hack to resolve the problem in the hopes it will help others to solve the same problem.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/","og_locale":"en_US","og_type":"article","og_title":"Linux laptop wont connect to wifi after suspend? A quick and dirty solution. - Linux Digest","og_description":"Recently I had this problem with my Lenovo laptop where it wouldn't connect to wifi after it resumed from sleep. I'm sharing the quick and dirty hack to resolve the problem in the hopes it will help others to solve the same problem.","og_url":"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/","og_site_name":"Linux Digest","article_published_time":"2023-01-31T21:36:10+00:00","article_modified_time":"2023-01-31T22:30:23+00:00","og_image":[{"width":1280,"height":740,"url":"https:\/\/linuxdigest.com\/wp-content\/uploads\/2023\/01\/no-wifi-2.jpg","type":"image\/jpeg"}],"author":"The Linux Digest Guy","twitter_card":"summary_large_image","twitter_misc":{"Written by":"The Linux Digest Guy","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/#article","isPartOf":{"@id":"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/"},"author":{"name":"The Linux Digest Guy","@id":"https:\/\/linuxdigest.com\/#\/schema\/person\/29c97230aa94affab929a88c6a10adb2"},"headline":"Linux laptop wont connect to wifi after suspend? A quick and dirty solution.","datePublished":"2023-01-31T21:36:10+00:00","dateModified":"2023-01-31T22:30:23+00:00","mainEntityOfPage":{"@id":"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/"},"wordCount":566,"commentCount":0,"publisher":{"@id":"https:\/\/linuxdigest.com\/#organization"},"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/","url":"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/","name":"Linux laptop wont connect to wifi after suspend? A quick and dirty solution. - Linux Digest","isPartOf":{"@id":"https:\/\/linuxdigest.com\/#website"},"datePublished":"2023-01-31T21:36:10+00:00","dateModified":"2023-01-31T22:30:23+00:00","description":"Recently I had this problem with my Lenovo laptop where it wouldn't connect to wifi after it resumed from sleep. I'm sharing the quick and dirty hack to resolve the problem in the hopes it will help others to solve the same problem.","breadcrumb":{"@id":"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/linuxdigest.com\/howto\/linux-laptop-wont-connect-to-wifi-after-suspend-a-quick-and-dirty-solution\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/linuxdigest.com\/"},{"@type":"ListItem","position":2,"name":"Linux laptop wont connect to wifi after suspend? A quick and dirty solution."}]},{"@type":"WebSite","@id":"https:\/\/linuxdigest.com\/#website","url":"https:\/\/linuxdigest.com\/","name":"Linux Digest","description":"Linux tutorials for everyone","publisher":{"@id":"https:\/\/linuxdigest.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/linuxdigest.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/linuxdigest.com\/#organization","name":"Linux Digest","url":"https:\/\/linuxdigest.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxdigest.com\/#\/schema\/logo\/image\/","url":"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/logo1.png","contentUrl":"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/logo1.png","width":1102,"height":170,"caption":"Linux Digest"},"image":{"@id":"https:\/\/linuxdigest.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/linuxdigest.com\/#\/schema\/person\/29c97230aa94affab929a88c6a10adb2","name":"The Linux Digest Guy","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxdigest.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ac6bcf745dec6961360ccf2d2711f26c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ac6bcf745dec6961360ccf2d2711f26c?s=96&d=mm&r=g","caption":"The Linux Digest Guy"}}]}},"_links":{"self":[{"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/posts\/2042"}],"collection":[{"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/comments?post=2042"}],"version-history":[{"count":2,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/posts\/2042\/revisions"}],"predecessor-version":[{"id":2044,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/posts\/2042\/revisions\/2044"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/media\/2052"}],"wp:attachment":[{"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/media?parent=2042"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/categories?post=2042"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/tags?post=2042"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}