I was trying to set up an ad-hoc network on my Raspberry Pi 4 and now the WiFi is not working. If I try to run ifconfig there is no wlan0 interface that shows up. I have also tried to manually change the WiFi settings but it gives the error message "Could not communicate with wpa_supplicant". When I hover my mouse over the WiFi GUI, it gives me the error message "Connection to dhcpcd lost". I have gone through the /etc/network/interfaces file and deleted all the changes that I made to it and rebooted, but still not change. Does anyone else have any ideas on how to fix this?
I assume you are using Raspbian. On this,
dhcpcd is configured to support normal networking out of the box, e.g. use WiFi in managed mode with hook scripts in
/lib/dhcpcd/dhcpcd-hooks/. I'm fairly sure that
dhcpcd does not support an ad-hoc network with this configuration so you have to do it all by hand.
I suggest to use systemd-networkd to setup an ad-hoc network because it is strait forward and can do very good "unusual" networking. Look at How to setup an unprotected Ad Hoc (IBSS) Network and if possible with WPA encryption?.