There are probably a variety of answers that could be applicable here, depending on what exactly causes your distractions. It won't be one-size-fits-all.
One thing that really helps me is the Pomodoro Technique. In a nutshell, what that means is you pick a task to work on, and then set a timer for 25 minutes. While the timer is running, you force yourself to work on the task and nothing else.When the time ends, you get a 5 minute break. (If I'm in the zone, I usually just keep going, though. Forcing yourself to take a break when you're in the zone is usually a poor tradeoff.)
For me, personally, since I am always on a computer, the key to making this actually work has been installing a Chrome add-on (specifically, this one) that actually doesn't let you visit distraction sites that you've blacklisted while the 25 minutes is running. It happens all the time where I find myself subconsciously navigating to all sorts of distraction websites while I was supposed to be working, but then the add-on blocks the page temporarily. Seeing the "error" message reminds me that I'm supposed to be working on something else, and I get back on track pretty quickly.
You mentioned getting sidetracked by Reddit and Hacker News, so something like this might be helpful to you as well, but it of course won't apply to all people in all situations.
In a similar vein, I know a lot of solo founders that use RescueTime in a similar way. I know it has a lot more features, some of which cost money. I've never used it myself, but it may be worth looking into.