The very first thing I'd do is look at the trailer plug. Take it apart, look for ants that may have built a nest in there, or just salt trails. It's supposed to be clean. Exposed wires that make a connection may be hard to see against the black background so use a torch and a small screwdriver to drag along the plastic between the connections.
Next is to look at the wiring behind the tail lights where they normally make the connections for trailer plugs and make sure everything is in good order there.
If you have an electric brake controller installed (may be a difficult-to-see unit in the dash, and may just appear as a button) disconnect this unit and check its wiring to ensure it's not exposed and touching something under the dash.