Here are two relevant counterexamples:

Let $R$ be a ring and $I$ an ideal, then the morphism $\operatorname{Spec} R[x]/(x-x^2,Ix) \to \operatorname{Spec} R$ has connected fibers outside $V(I)$ but disconnected fibers inside $V(I)$. This suggests that some kind of flatness condition is unavoidable.

Let $R$ be a non-Henselian local ring and let $f$ be an irreducible polynomial that factors into coprime polynomials modulo the maximal ideal. Then $\operatorname{Spec} R[x]/f(x) \to \operatorname{Spec} R$ has connected generic fiber but disconnected special fiber. This suggests that some sort of geometric connectedness condition fro the generic fiber is unavoidable.

But we do not always need the generic fiber to be "completely" geometrically connected. Let $Y=\operatorname{Spec} k[[x]]$, then if the generic fiber of a flat proper morphism $f: X \to Y$ is connected, then the special fiber is connected. This is because $f_* \mathcal O_X$ is a finite flat algebra. After inverting $x$, and ignoring nilpotents, it injects into a finite field extension of $k((x))$, which must be the field of fractions of a complete local ring, so it itself is a complete local ring.

Presumably we should formulate the most general version locally, with $Y$ the spectrum of a local ring $R$, for simplicity. A sufficient flatness condition is that the morphism is flat, or that $f_* \mathcal O_X$ is flat. A sufficient connectedness condition is that the fiber over the "Henselian generic point", the spectrum of the field of fractions of the Henselization or completion of $R$, is connected.

We can see this by reducing the connectedness of $X$ to the connectedness of the second half of Stein factorization via Zariski's connectedness theorem. We reduce to the case where $R$ itself is Henselian by completing. Then $f_* \mathcal O_X$ is an $R$-algebra which injects into a connected algebra over the field of fractions of $R$, so modulo nilpotents, which we can safely ignore, it injects into a finite field extension of $R$.

Assume that the special fiber is disconnected, that is, $f_* \mathcal O_X/m$ contains an idempotent mod $m$. Lift that idempotent to $f_* \mathcal O_X$, and compute its minimal polynomial. This is irreducible, so by Hensel's Lemma it has a unique root mod $m$, which must be either $0$ or $1$ since $x^2-x$ divides the minimal polynomial mod $m$, so the idempotent is equal to either $0$ or $1$, a contradiction.

geometricconnectedness). $\endgroup$ownStein factorization (say by using normality conditions together with some knowledge of a generic fiber) thenallfibers are geometrically connected. I assure you from experience that this is the manifestation of Zariski's connectedness principle that is most widely used in algebraic geometry. $\endgroup$4more comments