<p>I think I have a solution for this. Please follow the steps mentioned in this <a href="https://github.com/gpokhark/Octopi_Setting" rel="nofollow noreferrer">Github page of mine</a> for the Wifi connectivity issue. I rarely have any issues with the wifi signal dropping randomly.</p>
<hr />
<p>Wi-Fi connectivity issue</p>
<ul>
<li><p>Ensure that you have set up a static IP address for your Raspberry Pi.</p>
</li>
<li><p>Ensure that the command <code>sudo ifconfig wlan0 up</code> and <code>sudo ifconfig wlan0 down</code> works without the user password requirement.</p>
</li>
<li><p>To run the aforementioned commands without a password, do the following steps:</p>
<pre><code>sudo nano /etc/sudoers.d/010_pi-nopasswd
</code></pre>
<ul>
<li><p>Add the following line to the file</p>
<pre><code>pi ALL=(ALL) NOPASSWD: /sbin/ifconfig wlan0 up, /sbin/ifconfig wlan0 down
</code></pre>
<p>Here <code>pi</code> indicates the username of the Raspberry; update it as per your name.</p>
</li>
</ul>
</li>
<li><p>Try running the commands <code>sudo ifconfig wlan0 up</code> and <code>sudo ifconfig wlan0 down</code>, it shouldn't ask for a password.</p>
</li>
<li><p>Beware before running the previous command ensure that you have not recently typed the password for any other <code>sudo</code> command or else try this in a new terminal.</p>
</li>
<li><p>To know more about this search the command <code>sudo visudo</code></p>
</li>
</ul>
<p><code>check_wifi.sh</code> - script to check if Raspberry Pi is still connected to the wifi or not. If not then it restarts the wlan0.</p>
<pre><code>#!/bin/sh
# keep wifi alive
if ping -c3 192.168.0.1 #router ip address
then
    echo &quot;......&quot;
    echo &quot;No network connection, restarting wlan0&quot;

    sudo ifconfig wlan0 down
    sleep 30
    sudo ifconfig wlan0 up

else
    echo &quot;Wifi working normally.&quot;
fi
</code></pre>
<ul>
<li><p>Add a cron job to check the WiFi connectivity every 5 minutes - <code>sudo crontab -e</code></p>
<pre><code># cron job for checking the wifi connection every 5 minutes
*/5 * * * * /home/pi/Octopi_Setting/check_wifi.sh &gt; /dev/null 2&gt;&amp;1
</code></pre>
</li>
</ul>
<p>Additional resources:</p>
<ul>
<li><a href="https://www.cyberciti.biz/faq/linux-show-what-cron-jobs-are-setup/" rel="nofollow noreferrer">How to list, display and view all cron jobs in Linux</a></li>
<li><a href="https://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/" rel="nofollow noreferrer">How To Add Jobs To cron Under Linux or UNIX</a></li>
<li><a href="https://forums.fedoraforum.org/showthread.php?180471-Editing-sudoers-to-allow-ifconfig-only-on-certain-interfaces" rel="nofollow noreferrer">Editing sudoers to allow ifconfig only on certain interfaces</a></li>
<li><a href="https://unix.stackexchange.com/questions/163347/add-test-user-to-the-sudoers-file-to-run-ifconfig">Add test user to the sudoers file, to run ifconfig</a></li>
</ul>

CC BY-SA 4.0
2022-08-24T01:26:53.920Z
I have made some formatting changes to be more in line with the site's guidelines. Please review your answer to make sure I didn't mess anything up.
agarza
CC BY-SA 4.0
2022-08-24T04:55:24.003Z
I added in a disclosure; going forward, please remember to always mention when you are linking to a resource of your own as per the [promotion policy.](/help/promotion)
tripleee
CC BY-SA 4.0
2022-08-23T23:52:05.173Z
2022-08-24T12:24:35.140Z
2022-08-24T12:24:35.140Z
gpokhark
<p>I recently installed Octopi on my Raspberry Pi 4 and noticed some unusual behavior in that I lose the Wifi connection every 5-10 minutes immediately after boot. Once disconnected, I cannot re-establish the connection because my network's SSID doesn't even appear in the network list anymore. The only way I can re-establish the connection is to reboot the device.</p>
<p>With that said, I did find a troubleshooting discussion of similar problems at octoprint.org: <a href="https://community.octoprint.org/t/octopi-losing-network-connection-mid-print/16315" rel="nofollow noreferrer">OctoPi losing network connection mid-print</a>.</p>
<p>Following the various advice, I must have tried about 12 different things, but none of them have fixed my issue. At first, I thought that wifi power-save mode was the most likely culprit. <code>iw wlan0 get power_save</code> indicated that power-save mode was turned on, but then I turned it off with <code>iw wlan0 set power_save off</code> and the wifi <em>still</em> disconnects.</p>
<p>Going a step further, I set up a script to run the <code>iw</code> command right after boot so that the change is made permanent, but that didn't work either.</p>
<p>Other troubleshooting attempts I tried:</p>
<ul>
<li>Verified there is adequate power</li>
<li>Configured with settings for hidden
SSID (even though mine is not hidden)</li>
<li>Set up a reconnection script
that doesn't work because it can't find the network</li>
<li>Properly set up
regional settings</li>
</ul>
<p>I am at my wit's end.</p>
<p>As for my setup, I have an 8 GB Raspberry Pi 4 and am using an image of OctoPi 0.18.0 with OctoPrint 1.7.3. This I downloaded and imaged onto a 128 GB micro-SD card using the Raspberry Pi Imager. My wifi network is 2.5 GHz secured with WPA2 with a visible SSID and is definitely within close range. One way that I know that it is not a hardware issue is because I have another image with the Raspberry Pi OS 64-bit version and wifi works just fine when I run that.</p>
<p>As for Octopi, one atypical difference is that I <em>am</em> running it with a desktop. It may be that, for whatever reason, perhaps that particular distribution of RPi OS has a major bug in it? If so, then maybe I do have a solution, but I don't want to run without a desktop because I have a nice setup on my 3D printer that includes a touch screen. Given that is the case, could I maybe use the 64-bit Raspberry Pi OS and just load OctoPrint onto it with <code>sudo apt-get [package-name]</code> or something like that?</p>
<p>Any additional troubleshooting advice is much appreciated, but I suspect that not much else will work. I am not a greenhorn when it comes to linux-bases systems, but this is my first time trying out an image using Octopi.</p>

CC BY-SA 4.0
2022-04-27T13:52:36.473Z
It's probably something awful with whatever desktop-environment-integrated network manager you installed. These days a number of them (particularly whatever Android and ChromeOS are using, but I wouldn't surprise me if it's some of the same underlying software logic) are outright malicious about aggressively disconnecting and shadow-blocking networks they've decided are "low quality".
R.. GitHub STOP HELPING ICE
CC BY-SA 4.0
2022-04-27T20:56:32.053Z
@R..GitHubSTOPHELPINGICE Yikes! I have a 1GB fiber connection and regularly get speeds in excess of 250 mbps over my wifi connection so I would not have guessed it could be a network manager doing such things. Any command that I could run to check and see?
Joshua Dannemann
CC BY-SA 4.0
2022-04-27T23:47:29.907Z
I'd love to know so I could get Google devices to stop doing it... It doesn't seem to be a matter of bandwidth, but of how often the radio signal experiences disruption, and also something to do with WPA rekeying intervals. It's been over a year since I dug into it and didn't get anywhere solving the problem.
R.. GitHub STOP HELPING ICE
<octoprint><raspberry-pi><wi-fi>
Wifi goes down in Octoprint after 5-10 minutes with reboot required to reconnect
Joshua Dannemann
# Wifi goes down in Octoprint after 5-10 minutes with reboot required to reconnect

(Asked by: username_0 on 2022-04-26)

I recently installed Octopi on my Raspberry Pi 4 and noticed some unusual behavior in that I lose the Wifi connection every 5-10 minutes immediately after boot. Once disconnected, I cannot re-establish the connection because my network's SSID doesn't even appear in the network list anymore. The only way I can re-establish the connection is to reboot the device.

With that said, I did find a troubleshooting discussion of similar problems at octoprint.org: [OctoPi losing network connection mid-print](https://community.octoprint.org/t/octopi-losing-network-connection-mid-print/16315).

Following the various advice, I must have tried about 12 different things, but none of them have fixed my issue. At first, I thought that wifi power-save mode was the most likely culprit. `iw wlan0 get power_save` indicated that power-save mode was turned on, but then I turned it off with `iw wlan0 set power_save off` and the wifi *still* disconnects.

Going a step further, I set up a script to run the `iw` command right after boot so that the change is made permanent, but that didn't work either.

Other troubleshooting attempts I tried:

* Verified there is adequate power
* Configured with settings for hidden
  SSID (even though mine is not hidden)
* Set up a reconnection script
  that doesn't work because it can't find the network
* Properly set up
  regional settings

I am at my wit's end.

As for my setup, I have an 8 GB Raspberry Pi 4 and am using an image of OctoPi 0.18.0 with OctoPrint 1.7.3. This I downloaded and imaged onto a 128 GB micro-SD card using the Raspberry Pi Imager. My wifi network is 2.5 GHz secured with WPA2 with a visible SSID and is definitely within close range. One way that I know that it is not a hardware issue is because I have another image with the Raspberry Pi OS 64-bit version and wifi works just fine when I run that.

As for Octopi, one atypical difference is that I *am* running it with a desktop. It may be that, for whatever reason, perhaps that particular distribution of RPi OS has a major bug in it? If so, then maybe I do have a solution, but I don't want to run without a desktop because I have a nice setup on my 3D printer that includes a touch screen. Given that is the case, could I maybe use the 64-bit Raspberry Pi OS and just load OctoPrint onto it with `sudo apt-get [package-name]` or something like that?

Any additional troubleshooting advice is much appreciated, but I suspect that not much else will work. I am not a greenhorn when it comes to linux-bases systems, but this is my first time trying out an image using Octopi.

**Tags:** octoprint, raspberry-pi, wi-fi
> **Comments:**
> **username_1**: It's probably something awful with whatever desktop-environment-integrated network manager you installed. These days a number of them (particularly whatever Android and ChromeOS are using, but I wouldn't surprise me if it's some of the same underlying software logic) are outright malicious about aggressively disconnecting and shadow-blocking networks they've decided are "low quality".  
> **username_0**: @R..GitHubSTOPHELPINGICE Yikes! I have a 1GB fiber connection and regularly get speeds in excess of 250 mbps over my wifi connection so I would not have guessed it could be a network manager doing such things. Any command that I could run to check and see?  
> **username_1**: I'd love to know so I could get Google devices to stop doing it... It doesn't seem to be a matter of bandwidth, but of how often the radio signal experiences disruption, and also something to do with WPA rekeying intervals. It's been over a year since I dug into it and didn't get anywhere solving the problem.  

---

## 1 answers

### Answer by username_2 on 2022-08-23. Score: 3 | Accepted answer

I think I have a solution for this. Please follow the steps mentioned in this Github page of mine for the Wifi connectivity issue. I rarely have any issues with the wifi signal dropping randomly.

Wi-Fi connectivity issue

Ensure that you have set up a static IP address for your Raspberry Pi.

Ensure that the command sudo ifconfig wlan0 up and sudo ifconfig wlan0 down works without the user password requirement.

To run the aforementioned commands without a password, do the following steps:
sudo nano /etc/sudoers.d/010_pi-nopasswd


Add the following line to the file
pi ALL=(ALL) NOPASSWD: /sbin/ifconfig wlan0 up, /sbin/ifconfig wlan0 down

Here pi indicates the username of the Raspberry; update it as per your name.



Try running the commands sudo ifconfig wlan0 up and sudo ifconfig wlan0 down, it shouldn't ask for a password.

Beware before running the previous command ensure that you have not recently typed the password for any other sudo command or else try this in a new terminal.

To know more about this search the command sudo visudo


check_wifi.sh - script to check if Raspberry Pi is still connected to the wifi or not. If not then it restarts the wlan0.
#!/bin/sh
# keep wifi alive
if ping -c3 192.168.0.1 #router ip address
then
    echo "......"
    echo "No network connection, restarting wlan0"

    sudo ifconfig wlan0 down
    sleep 30
    sudo ifconfig wlan0 up

else
    echo "Wifi working normally."
fi


Add a cron job to check the WiFi connectivity every 5 minutes - sudo crontab -e
# cron job for checking the wifi connection every 5 minutes
*/5 * * * * /home/pi/Octopi_Setting/check_wifi.sh > /dev/null 2>&1



Additional resources:

How to list, display and view all cron jobs in Linux
How To Add Jobs To cron Under Linux or UNIX
Editing sudoers to allow ifconfig only on certain interfaces
Add test user to the sudoers file, to run ifconfig

> **Comments:**
> **username_3**: I have made some formatting changes to be more in line with the site's guidelines. Please review your answer to make sure I didn't mess anything up.  
> **username_4**: I added in a disclosure; going forward, please remember to always mention when you are linking to a resource of your own as per the [promotion policy.](/help/promotion)  

---

