Try settings > general > transfer or reset > reset > reset network settings.
Apple
A place for Apple news, rumors, and discussions.
I have done it multiple times
I was going to suggest the reset of just network settings as well. But if that hasn’t worked for you it’s possible there is a software glitch.
If it connects after restarting or resetting network settings for a while then fails it’s likely software. If it never works then is could be hardware.
Start an apple support ticket ( i use chat but they can call too) and they can walk you through re-installing your software. But first back up your device
Good luck
Try resetting the device from the router, if you’ve not done it before your ISP will have a sticker on the device with the login info. It may be toggled for a “static IP” setting or maybe the router is on an unsupported bandwidth. You might also be able to turn off the light in your router if you like, or move your whole network to 5Ghz from 2.4+5 if you’re not using those devices, or see if there’s unexpected devices on the network
Are you sure it's even the iPhone? If it's showing you're connected to your WiFi, but there is no internet, then the connection to the WiFi may very well be fine. And your WiFi/Modem may just not have an outside connection to the internet.
How are other devices that are connected to your WiFi?