Usually a bad ground contact in the light assembly contact. If you disconnect the connector, usually one (or more) of the contacts is corroded. Scrape clean with a little screw-driver or something the male contacts in the housing, bend the female contacts in the connector a bit for tighter contact. Stick the contact back in. If it works, take it out again and put some grease or even better battery-pole lube on to keep future corrosion at bay.