Had that happen on both of mine. First one side, then the other. First time the headlight would come and go, then it was dim. Second one just went out. I knew wha tit was right off the second time after some lengthy exploring on the first one.
I checked grounds, I cleaned connectors, I swapped lenses. All to no effect.
It seemed that the wires flex everytime the headlights go up and down. As the grommets harden and the wire insulation hardens over time, the ability for the wires to flex lessens. The wires eventually crack and create a short. On the second light, one wire broke clean in half.
At some point I will do all new wires from the bucket out to the loom in the engine bay, but for now, I spliced in new wire at the flex points. Made it a little longer and made sure it would stay out of the way as the headlights cycled up and down. They have been fine ever since.