In the category of rings, what is an example of an epimorphism that is not a retraction? It seems to me that if you have a epimorphism $f:R\to S$ , then $f$ is surjective.
I want to show that there is no $g:S\to R$ such that $f \circ g = 1_S$. But could we not define $g$ to be a constant map sending every element in $S$ to the element $r$ in $R$ such that $f(r) = 1_S$ thus finding the homomorphism we need, and showing that $f$ is indeed a retraction? 
 A: For start it isn't always the case that an epimorphism is surjective, at least in $\mathbf{Ring}$.
A counterexample is given by the canonical embedding of $i \colon \mathbb Z \to \mathbb Q$. This mapping is an epimorphism because for every pair $f,g \colon \mathbb Q \to L$ if $f \circ i=g \circ i$ then by the universal property of $i$ (or if you prefer since $\mathbb Q$ is the field of fraction for $\mathbb Z$) it follows that $f=g$, but $i$ is not a surjective mapping.
A: (All my rings are unital, and all my ring homomorphisms preserve $1$.)
As Giorgio explains, not every epimorphism in $\mathbf{Ring}$ is a surjective homomorphism. Furthermore, its also the case that not every surjective homomorphism of rings is a retraction.
To see this, use:

Proposition. Let $n$ denote a non-zero natural number. Then there is no ring homomorphism $$\mathbb{Z}/n\mathbb{Z} \rightarrow \mathbb{Z}.$$

Trivially, this implies that the projection $$\mathbb{Z} \rightarrow \mathbb{Z}/n\mathbb{Z}$$ does not have a section $$\mathbb{Z}/n\mathbb{Z} \rightarrow \mathbb{Z}.$$
In other words, the projection $\mathbb{Z} \rightarrow \mathbb{Z}/n\mathbb{Z}$ is not a retraction.
Proof of proposition. Suppose for a contradiction that that $f : \mathbb{Z}/n\mathbb{Z} \rightarrow \mathbb{Z}$ is a ring homomorphism. Then $\mathrm{img}(f)$ is a subring of $\mathbb{Z}$. But since $n$ is non-zero, hence the domain of $f$ is finite. Thus $\mathrm{img}(f)$ is finite. So we deduce there exists a subring of $\mathbb{Z}$ that is finite. But since $\mathbb{Z}$ is infinite, we deduce in particular that there exists a subring of $\mathbb{Z}$ that is distinct from $\mathbb{Z}$.
But this contradicts the fact that the only subring of $\mathbb{Z}$ is $\mathbb{Z}$ itself.
A: More generally, for any multiplicative set in a ring $R$, the canonical morphism $R\longrightarrow S^{-1}R$ is a (flat) epimorphism.
It is known that if $f\colon R\longrightarrow S $ is a finite epimorphism, then $f$ is surjective.
Also:


*

*a flat, local epimorphism between local rings is surjective.

*if $R$ is artinian, an epimorphism $f\colon R\longrightarrow S $ is surjective


An example of an epimorphism that is useful for many counter-examples is the canonical map:
$$R\longrightarrow R_s\times R/sR\quad (s\in R)$$
where $R_s$ denotes the ring of fractions with denominator some $s^k$.
If you can read (mathematical) French, there was a most interesting seminar of Pierre Samuel during the academic year 1967-1968 centred on ring epimorphisms available here.
