How to fix Raspberry Pi 5 not connecting to Wifi after fresh install

If your Raspberry Pi 5 is not connecting to Wifi after a fresh install using rpi-imager, use raspi-config -> System Options -> S1 to re-configure your wifi network. This was the only method that worked for me.

How to get to raspi-config if you have no Wifi? I recommend using an Ethernet cable and then connecting via SSH.

Even though raspi-config showed an error message after configuring the wifi, it worked (even after reboot).

Possibly you also need to configure your locale and timezone using raspi-config, but for me, just re-configuring it via raspi-config worked fine.