Let (X,B) be a pair, and let f :X S be a contraction with -(K-x+B) nef over S. A conjecture, known as the Shokurov-Kollar connectedness principle, predicts thatf(-1) (s) boolean AND Nklt(X,B) has at most two connected components, where s is an element of S is an arbitrary schematic point and Nklt(X,B) denotes the non-klt locus of (X,B). In this work, we prove this conjecture, characterizing those cases in which Nklt(X,B) fails to be connected, and we extend these same results also to the category of generalized pairs. Finally, we apply these results and the techniques to the study of the dual complex for generalized log Calabi-Yau pairs, generalizing results of Kollar-Xu [Invent. Math. 205 (2016), 527-557] and Nakamura [Int. Math. Res. Not. IMRN 13 (2021), 9802-9833].