This can have various possibilities.
If you are using Wi-Fi, then make sure you are in a good coverage area of the Wi-Fi zone and always keep your router firmware up to date.
If you are using mobile data, then make sure you are in a good network coverage area and also check your data pack speed limitations and FUP.
And finally, check if your phone is blocking connectivity. For example, battery saving modes will block internet and allow only calls to save battery, so you need to disable them.