How to fix a socket that works and doesn't work and has a switch in the cord. It is a small one the size of a chandelier bulb.
The contact in the light socket might be bent too far down.  Unplug the device, remove the lightbulb, gently bend the contact up a little.  The light should work awesomely then.