The gravitational self-force (GSF) and post-Newtonian (PN) schemes are complementary approximation methods for modeling the dynamics of compact binary systems. Comparison of their results in an overlapping domain of validity provides a crucial test for both methods and can be used to enhance their accuracy, e.g. via the determination of previously unknown PN parameters. Here, for the first time, we extend such comparisons to noncircular orbits-specifically, to a system of two nonspinning objects in a bound (eccentric) orbit. To enable the comparison we use a certain orbital-averaged quantity hUi that generalizes Detweiler's redshift invariant. The functional relationship hUiðΩ r ; Ω ϕ Þ, where Ω r and Ω ϕ are the frequencies of the radial and azimuthal motions, is an invariant characteristic of the conservative dynamics. We compute hUiðΩ r ; Ω ϕ Þ numerically through linear order in the mass ratio q, using a GSF code which is based on a frequency-domain treatment of the linearized Einstein equations in the Lorenz gauge. We also derive hUiðΩ r ; Ω ϕ Þ analytically through 3PN order, for an arbitrary q, using the known near-zone 3PN metric and the generalized quasi-Keplerian representation of the motion. We demonstrate that the OðqÞ piece of the analytical PN prediction is perfectly consistent with the numerical GSF results, and we use the latter to estimate yet unknown pieces of the 4PN expression at OðqÞ.