Your problem isn't in the hub, it's in the freehub body. The pawls aren't engaging when they should. Drip a lot of light oil into the annular space between the stationary core and rotating body of the freehub and see if that corrects the problem. Otherwise you need a new freehub body.
If the bike is old enough to use a freewheel, the same corrective action and outcome apply.