The near-surface motility of bacteria is important in the initial formation of biofilms and in many biomedical applications. The swimming motion of Escherichia coli near a solid surface is investigated both numerically and experimentally. A boundary element method is used to predict the hydrodynamic entrapment of E. coli bacteria, their trajectories, and the minimum separation of the cell from the surface. The numerical results show the existence of a stable swimming distance from the boundary that depends only on the shape of the cell body and the flagellum. The experimental validation of the numerical approach allows one to use the numerical method as a predictive tool to estimate with reasonable accuracy the near-wall motility of swimming bacteria of known geometry. The analysis of the numerical database demonstrated the existence of a correlation between the radius of curvature of the near-wall circular trajectory and the separation gap. Such correlation allows an indirect estimation of either of the two quantities by a direct measure of the other without prior knowledge of the cell geometry. This result may prove extremely important in those biomedical and technical applications in which the near-wall behavior of bacteria is of fundamental importance.