Why your Raspberry Pi won’t connect to Wi-Fi—and the easy fix

Construction Photography/Avalon/GettyImages

If you have been tinkering with the Elecrow Pi Terminal or another device that uses the Raspberry Pi as the main processor and have been having issues getting Wi-Fi to work, you’re not alone. Many users find themselves searching the internet and asking ChatGPT for help but keep reading, and we’ll show you an easy way to get it working.

Understanding the issue: Conflicting network routes

The Pi Terminal is a versatile tool that allows you to connect and control a wide range of devices and can work with Wi-Fi, Bluetooth, 5G internet, LoRa, and more. This allowance for multiple network interfaces is the root of our problem.

Many users encounter problems when their Pi Terminal connects to the internet via USB (using usb0), but they actually want to use Wi-Fi instead. The system might automatically set usb0 as the default gateway, preventing wlan0 from working properly. In other words, even though the Wi-Fi is connected, network traffic is still trying to go through the USB interface (usb0), which can cause connectivity problems.

How to find the problem

The first clue that you might be having this problem is that your device has the wrong time. The Raspberry Pi connects to the internet for the current time since it doesn’t have an internal battery to save it when the device is powered down. You will also not be able to use the internet browser to surf the web. If this is the case, you’ll need to look deeper into the system.

In your terminal, run the following command: ip route

Look at the response for the term “default” at the beginning of the line. In my case, the response had the term in two locations. One mentioned Wi-Fi, but the other mentioned usb0 in a line similar to this:  default via 192.168.10.1 dev usb0 proto dhcp metric 100

If you see a similar line in your code, this next fix will likely help.

Breaking down the fix

Opening a terminal and running the following command should instruct your Pi Terminal or other device to use the Wi-Fi instead of the USB.

sudo IP route del default via 192.168.10.1 dev usb0

The code will delete the default route assigned to usb0, allowing the system to prioritize your Wi-Fi connection. After several seconds, you should see that your time is correct and that you can surf the internet.

Top modern programming languages driving the future of development

Making it permanent

If the above line of code worked for you, you’ll likely want to make it permanent. As it is, you will need to reenter the code every time you power up your device.

To make it permanent, enter the following code into your terminal to open the crontab editor:

crontab -e

Next, add this line at the bottom of the file and save it. When you restart your device, it should work correctly from the start.

Follow GeekSided for more tips on using the Raspberry Pi