Can't connect to Wifi with pi4

Hi, I’m trying to get my Pi4 connected to wifi (headless, no hdmi or whatsoever) and it finds the network but never connects. It always says: SSID: Disconnected.

tried with 2 different networks, one hidden (WPA2) and one public (WPA3). Nothing seem to works. Bands are available for both (2.4 and 5).

If that helps, I’m also using eth as primary interface, but would like to enable wifi as a second available interface for some services.

Thank you.

So your WiFi has been found if you hit SCAN option?

Once configured, you would need to hit Apply to save all changes and restart networking.

Afterwads you should see something like this for the DHCP request on both interfaces

[  OK  ] DietPi-Config | systemctl daemon-reload
Internet Systems Consortium DHCP Client 4.4.3-P1
Copyright 2004-2022 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eth0/d8:3a:dd:c0:0e:c3
Sending on   LPF/eth0/d8:3a:dd:c0:0e:c3
Sending on   Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 8
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 17
DHCPOFFER of 192.168.0.24 from 192.168.0.11
DHCPREQUEST for 192.168.0.24 on eth0 to 255.255.255.255 port 67
DHCPACK of 192.168.0.24 from 192.168.0.11
bound to 192.168.0.24 -- renewal in 38918 seconds.
Internet Systems Consortium DHCP Client 4.4.3-P1
Copyright 2004-2022 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/wlan0/d8:3a:dd:c0:0e:c4
Sending on   LPF/wlan0/d8:3a:dd:c0:0e:c4
Sending on   Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 7
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 9
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 14
DHCPOFFER of 192.168.0.127 from 192.168.0.11
DHCPREQUEST for 192.168.0.127 on wlan0 to 255.255.255.255 port 67
DHCPACK of 192.168.0.127 from 192.168.0.11
bound to 192.168.0.127 -- renewal in 40592 seconds.
[ INFO ] DietPi-Config | Reloading networking data, please wait...
[  OK  ] DietPi-Config | Network restarted

Yes, I saw all of that, but apparently in the dietpi-config it still shows as a disconnected. Even after rebooting.

I’m trying to connect to a hidden network called “foo” which is 2.4 ghz. It uses WPA2-PSK. I’m entering the password in the field (on the dietpi-config) as well as I’ve tried to generate the hash and tried with it (because it suggested to generate a hash, but I’m not sure if that’s even necessary — anyway, tried both ways) it didn’t work.

I’ll post the logs back.

Edit: @Joulinar


Listening on LPF/wlan0/dc:a6:32:78:1f:68
Sending on LPF/wlan0/dc:a6:32:78:1f:68
Sending on Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 4
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 7
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 15
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 16
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 11
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 8
No DHCPOFFERS received.

No working leases in persistent database - sleeping.

The AP is broadcasting in the channel 1 (not sure if this interval is the channel it is looking for).

For reference the signal is good and strong where the Pi is.

ok did some testing on my demo RPi4B. Setup a test network on channel 1, SSID hidden and my RPi4 is connecting without issues.

Internet Systems Consortium DHCP Client 4.4.3-P1
Copyright 2004-2022 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/wlan0/dc:a6:32:e2:10:cf
Sending on   LPF/wlan0/dc:a6:32:e2:10:cf
Sending on   Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 7
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 14
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 13
DHCPOFFER of 192.168.2.41 from 192.168.2.1
DHCPREQUEST for 192.168.2.41 on wlan0 to 255.255.255.255 port 67
DHCPACK of 192.168.2.41 from 192.168.2.1
bound to 192.168.2.41 -- renewal in 874067 seconds.

Actually, it looks you don’t get an IP address assigned via DHCP. Did you already try STATIC IP instead?

Yes I did without luck.

Did you tried with the Ethernet also enabled as the main interface? Remember that I’m trying to set this up as a secondary interface. It doesn’t even connect to non hidden WiFi.

Basically it seems that I can’t connect to any WiFi network.

Yes. No issues to connect both at the same time. I do whole configuration via SSH connected thru Ethernet.

Does WiFi password has special character?

No, it’s just numbers and characters.

@Joulinar just to make sure, in this screen:

You are using the wifi password right? Because that warning saying that I need the hexadecimal returned from the wpa_passphrase confuses me. But anyway, I’ve tried both ways without success.

Running the status for wpa_supplicant returns this is it normal?

root@DietPi:~# systemctl status wpa_supplicant

**●** wpa_supplicant.service - WPA supplicant
Loaded: loaded (/lib/systemd/system/wpa_supplicant.service; enabled; vendor preset: enabled)
Active: **failed** (Result: exit-code) since Fri 2024-01-05 11:59:29 GMT; 12min ago
Main PID: 472 (code=exited, status=255/EXCEPTION)
CPU: 19ms
Jan 05 11:59:28 DietPi systemd[1]: Starting WPA supplicant...
Jan 05 11:59:29 DietPi wpa_supplicant[472]: **dbus: Could not acquire the system bus: org.freedesktop.DBus.Error.FileNotFound - Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory**
Jan 05 11:59:29 DietPi wpa_supplicant[472]: **Failed to initialize wpa_supplicant**
Jan 05 11:59:29 DietPi systemd[1]: **wpa_supplicant.service: Main process exited, code=exited, status=255/EXCEPTION**
Jan 05 11:59:29 DietPi systemd[1]: **wpa_supplicant.service: Failed with result 'exit-code'.**
Jan 05 11:59:29 DietPi systemd[1]: **Failed to start WPA supplicant.**

Yes, I simply type the regular WiFi password.

The service is not active for me.

root@DietPi4:~# systemctl status wpa_supplicant
○ wpa_supplicant.service - WPA supplicant
     Loaded: loaded (/lib/systemd/system/wpa_supplicant.service; disabled; preset: enabled)
     Active: inactive (dead)
root@DietPi4:~#

Probably you need to install dbus

apt install dbus -y
systemctl enable dbus && systemctl start dbus
systemctl restart wpa_supplicant

Done that but still no luck. That service was installed/activated by dietpi-config I believe. I didn’t install it manually.

I still get no DHCP offers.

Also, I got this:

root@DietPi:~# systemctl enable dbus && systemctl start dbus

Synchronizing state of dbus.service with SysV service script with /lib/systemd/systemd-sysv-install.

Executing: /lib/systemd/systemd-sysv-install enable dbus

The unit files have no installation config (WantedBy=, RequiredBy=, Also=,

Alias= settings in the [Install] section, and DefaultInstance= for template

units). This means they are not meant to be enabled using systemctl.

Possible reasons for having this kind of units are:

• A unit may be statically enabled by being symlinked from another unit's

.wants/ or .requires/ directory.

• A unit's purpose may be to act as a helper for some other unit which has

a requirement dependency on it.

• A unit may be started when needed via activation (socket, path, timer,

D-Bus, udev, scripted systemctl call, ...).

• In case of template units, the unit is meant to be enabled with some  instance name specified.

Edit: I’ve added another (non hidden) network to it and it doesn’t connect to that one as well (WPA3) the hidden is WPA2.

What is the output of following after reboot?

systemctl status wpa_supplicant
● wpa_supplicant.service - WPA supplicant
     Loaded: loaded (/lib/systemd/system/wpa_supplicant.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2024-01-05 14:12:09 GMT; 2h 51min ago
   Main PID: 7146 (wpa_supplicant)
      Tasks: 1 (limit: 4531)
        CPU: 160ms
     CGroup: /system.slice/wpa_supplicant.service
             └─7146 /sbin/wpa_supplicant -u -s -O /run/wpa_supplicant

Jan 05 14:12:09 DietPi systemd[1]: Starting WPA supplicant...
Jan 05 14:12:09 DietPi systemd[1]: Started WPA supplicant.
Jan 05 14:12:09 DietPi wpa_supplicant[7146]: Successfully initialized wpa_supplicant

Didn’t even had to reboot.

@MichaIng any ideas why WiFi is not connecting?

@miguelpruivo maybe you like to test with plain RPi OS if you have a spare SD card.

I’m still seeking some help here if someone is able to. :slight_smile:

if you have spare SD card, you could try plain RPi OS to see how it goes.

I don’t. But there must be some other way. It detects wifi just fine (when searching through the dietpi-config). But in never gets a DHCP lease after saving settings. Any tips?

By doing:

dmesg | grep wlan0
journalctl | grep wlan0

I can see:

Jan 18 23:52:19 DietPi wpa_supplicant[2379]: wlan0: Trying to associate with SSID 'TestNetwork'
Jan 18 23:52:22 DietPi wpa_supplicant[2379]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
Jan 18 23:52:25 DietPi wpa_supplicant[2379]: wlan0: Trying to associate with SSID 'TestNetwork'
Jan 18 23:52:28 DietPi wpa_supplicant[2379]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
Jan 18 23:52:31 DietPi wpa_supplicant[2379]: wlan0: Trying to associate with SSID 'TestNetwork'
Jan 18 23:52:33 DietPi wpa_supplicant[2379]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
Jan 18 23:52:37 DietPi wpa_supplicant[2379]: wlan0: Trying to associate with SSID 'TestNetwork'
Jan 18 23:52:40 DietPi wpa_supplicant[2379]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
Jan 18 23:52:40 DietPi wpa_supplicant[2379]: wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="TestNetwork" auth_failures=1 duration=10 reason=CONN_FAILED
Jan 18 23:52:50 DietPi wpa_supplicant[2379]: wlan0: CTRL-EVENT-SSID-REENABLED id=0 ssid="TestNetwork"
Jan 18 23:52:50 DietPi wpa_supplicant[2379]: wlan0: Trying to associate with SSID 'TestNetwork'
Jan 18 23:52:53 DietPi wpa_supplicant[2379]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
Jan 18 23:52:53 DietPi wpa_supplicant[2379]: wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="TestNetwork" auth_failures=2 duration=20 reason=CONN_FAILED

Found something on the RPI forum WiFi Stopped Connecting to Network: CTRL-EVENT-ASSOC-REJECT status_code=16 - Raspberry Pi Forums

It seems to refer something about rpi access point, but I’m not using it as an access point. I want to connect to the wifi, not using it as access point.

Also, worse than this (and may be the underlying issue) is that it 99% of the time, can’t find my 2.4 GHz network, only the 5 GHz.

What wifi router do you use?

Ubiquiti.

The access point that is close to the pi is a U6-Pro, but the network I’m looking for is a 2.4 ghz wpa2 so it shouldn’t have any issues Id say.