The way to fix this is to unplug both your modem and your router (you may have one piece of equipment that acts as both) and wait a full 60 seconds. Then plug them both in again and wait for all the lights to stop flashing. At that point, try to reconnect to the Internet again.
If restarting doesn't work, switch between Wi-Fi and mobile data: Open your Settings app and tap Network & internet or Connections. Depending on your device, these options may be different. Turn Wi-Fi off and mobile data on, and check if there's a difference.