Constraints
Make sure that the bodies are sufficiently constrained. If the bodies are not in contact in the initial configuration, and there are no constraints on them, there will be possible rigid body displacements. This causes the solver to fail and must be avoided.
Sometimes, as when simulating mounting processes, the structure is fully constrained only once the contact is fully established. There are some strategies for how you can deal with this problem.
Add a temporary weak spring during the beginning of the simulation. Assuming that a parameter p, ranging from 0 to 1, is used for applying the external load, you can introduce a stabilizing spring with stiffness kx in the x direction as
and similarly in any other direction that needs to be restrained. It is not important whether the spring is applied to domains, boundaries, or edges, but it should not create local forces. The value for the stiffness k should be chosen so that the force generated by the spring balances the external load at a sufficiently small displacement. A too weak spring will give a too large initial overclosure of the contact boundaries. A too stiff spring might influence the solution too much.