Welcome to MS........trust you'll hang around a while ?
Possible wiring loom connector/s breaking up inside.
With the engine idling, grab the loom under the hood, and wriggle it around gently..... try in several areas of the loom.
Are there any DTC logged ? have you had it checked at a shop ?
.