It'll be the connector, I had the exact same problem. Squirt of WD40 in the connector sorted it for me.
Ok. So just open up the rear light cluster and clean up the connections? Will try in daylight tomorrow. If it's the earth, where exactly is that located?
Yes - undo the two plastic screws holding the light cluster in place and undo the connector to inspect. It could be either side or both.