I’ve had this problem before, and it’s just eliminating the distractions. For example, deleting or silencing social media is a great place to start! The algorithm is to get you hooked, and once you know that, it’s just taking the steps to avoid it.
I am an online university student and spend a lot of time on the internet.
I personally don't like being on my phone and usually occupy myself with something else. I would take a nap, go for lunch or dinner with a friend or family, watch tv, play with my dog or exercise.
Setting an alarm for 30 minutes or two hours max can help too. It won't be easy but practice makes progress.