Buffer tube retainer keeps coming out

My retainer for the buffer took keeps popping out of place when the bolt comes back. And it causes it to jam. I've tried putting it back in the retainer hole but it doesn't lock in place I guess