  Let $K$ be a number field and $S$ a finite set of places of $K$ containing
all archimedean places. In this paper, we show that the second moment of the
number of $S$-integral points on elliptic curves over $K$ is bounded. In
particular, we prove that, for any positive real number $r\leq \log_2 5 =
2.3219 \ldots$, the $r$-th moment of the number of $S$-integral points is
bounded for the family of all integral short Weierstrass curves ordered by
height, or for any positive density subfamily thereof. For certain other
families of elliptic curves over $\mathbb{Q}$, such as those with one or two
marked points, we prove that the average of the number of integral points is
bounded; in fact, for the family with one marked point, the $r$-th moment is
also bounded for all positive $r\leq \log_2 3$.
  The essential new ingredient in our proof is an upper bound on the number of
$S$-integral points on an affine integral Weierstrass model $\mathcal{E}$ of an
elliptic curve $E$ over $K$ depending on the rank of the curve, the class group
and degree of $K$, and the number of primes of $K$ whose square divides the
discriminant of $\mathcal{E}$. For example, over $\mathbb{Q}$, the bound for
integral points on $\mathcal{E}$ is $2^{\mathrm{rank}{E(\mathbb{Q})}} O(1)^s$,
where $s$ is the number of prime squares dividing the discriminant of
$\mathcal{E}$.
  The theorems on moments then follow from averaging this new upper bound;
crucially, we can bound the average of the $2^{\mathrm{rank}}$ term by using
results on the average sizes of Selmer groups in the families. In order to
prove the bounds for the $r$-th moment when $r= \log_2 5$ (and the analogous
equality cases for the other families), we introduce a method to count orbits
of coregular representations with possibly unbounded weights.
