Wifi could not be joined because it does not have an IP address
On iMac 27 when using hotspot
On iMac 27 when using hotspot
Normally, when you connect to a Wi-Fi access point, you would have your Mac set up to Configure IPv4 using DHCP and to Configure IPv6 Automatically.
It would then be the router's job to assign IPv4 and IPv6 addresses to your Mac, and to provide other necessary info such as the subnet mask, and the router's own (gateway) IP addresses.
If your router is set up in such a way that it refuses to hand out this information to your Mac, that might be the cause of the problem. For instance, if you have your router set up to use MAC address "security" and to only offer service to devices with specific MAC addresses (MAC as in Media Access Control, not as in Macintosh), and you haven't let it know about the MAC address of your Mac's Wi-Fi interface, your router might be failing to provide the IP address information your Mac needs.
You have to provide more detailed information. There is not enough info in what you posted for people to help you here.
I suggest reading Writing an effective Apple Support Commun… - Apple Community especially
Step 1: Ask your question and
Step 2: Provide specific details
Wifi could not be joined because it does not have an IP address