Great question — answering as the UphillTech team:
Actually I think you have two problems. First, Recessed cans come with a thermal overload, so if the fixture heats up beyond normal the thermal protector turns it off. These protectors can get worn and will trip at random until replaced. You might see if you can access your can from above and if it is covered with insulation then you need to pull the insulation away from it so it will operate cooler. This might fix the problem, if not you will need to replace the unit. Unfortunately you really can't replace the thermal protector without replacing the can. This really isn't for a DIY, you need someone who knows how to get the parts, take down the bad parts and reassemble the fixture. Second,...
Full answer by Retired Master Electrician: https://diy.stackexchange.com/a/153205 (CC BY-SA 4.0).
Need it done for your business? UphillTech.