Have a look at the wires that clip on to the bulb, if they are used to yank the bulb free, you may find the wire has come away from the connector block, or pulled the spade terminal through the plastic plug. In either case, a motor factor will sell you a bare wired bulb connector that could be swapped in for the dodgy connector. Limited space, but a fairly easy fix.
If it isn't that, you'd be looking at a wire break or terminal break inside the headlight. Again, fix is similar, but you'd have to remove and split the headlight so at that point you're at a replacement headlight for cost effectiveness.
Before getting there, try a continuity check at the back of the headlight. See if the bulb in place gives a continuous circuit.
Could be as simply as grubby contacts between the car and the headlight socket.