Let R be a ring. The unit graph of R, denoted by G(R), is the simple graph defined on all elements of R, and where two distinct vertices x and y are linked by an edge if and only if x + y is a unit of R. The diameter of a simple graph G, denoted by diam(G), is the longest distance between all pairs of vertices of the graph G. In the present paper, we prove that for each integer n ≥ 1, there exists a ring R such that n ≤ diam(G(R)) ≤ 2n. We also show that diam(G(R)) ∈ {1, 2, 3, ∞} for a ring R with R/J(R) self-injective and classify all those rings with diam(G(R)) = 1, 2, 3 and ∞, respectively. This extends [12, Theorem 2 and Corollary 1].