Wierd Headlights

I recently drove somewhere one evening with my headlights working fine, then after parking the car and returning, my low beam lights suddenly did not work on either side. The high beams worked but not the low beams. I opened the hood and tried blindly tinkering accomplishing nothing, but then I closed the hood and lo’ and behold, the right headlight came on. I tried slapping the frong of the left headlight with my open palm and it came on. That method worked only for a very short while. My right headlight is still out and won’t come on no matter what. Any ideas what is going on?

Most cars have a relay to the headlamps. It sounds like one stuck and is now working again.  If it continues, I would look for that relay.

try unplugging the connector from each of your headlights, spraying the connector with contact cleaner and plugging the back in.