This is a question every aspiring writer asks, and unfortunately there’s no one good answer that suits everyone. There are all sorts of approaches from the staring at a blank sheet of paper to going out for a long walk, building a log cabin (Worked for Theroux) shopping, cooking, driving, running, jumping, swimming, fishing, bungee jumping, play games, arranging socks or some other displacement activity. Getting slobbering shitfaced drunk also seems to be a perennial favourite.
For myself, first move is to ‘head dump’. That is basically emptying out the garbage can of ideas into note form, and seeing if there’s anything that fits in with one of the projects I’m currently fiddling with. Sometime it works, sometimes there’s simply nothing worth recycling. If that doesn’t work, I’ll do some practical task like cooking which makes my hands and forebrain busy while the clever stuff goes on in my subconscious. There are times when simply overthinking a story builds up a massive logjam of worthless ideas choking the river of narrative. That’s when I get ruthless. I re read what I’ve already written, and junk anything that either doesn’t work, or detracts from the story I want to tell. Sometimes I’ll play games like killing off a character, just to see if that frees up a plot line. Anything to stir the sea of words into a storm to see if anything interesting gets washed up onto the beach from the deep subconscious.
Occasionally I’ll end up going off on a tangent, but mostly it seems to work.