We evaluate in a homogeneous way the optical masses of 170 nearby clusters (z <= 0.15). The sample includes both data from the literature and the new ESO Nearby Abell Clusters Survey (ENACS) data. On the assumption that mass follows the galaxy distribution, we compute the mass of each cluster by applying the virial theorem to the member galaxies. We constrain the masses of very substructured clusters (about 10% of our clusters) between two limiting values. After appropriate rescaling to the X-ray radii, we compare our optical mass estimates to those derived from X-ray analyses, which we compiled from the literature (for 66 clusters). We find a good overall agreement. This agreement is expected in the framework of two common assumptions: that mass follows the galaxy distribution and that clusters are not far from a situation of dynamical equilibrium, with both gas and galaxies reflecting the same underlying mass distribution. We stress that our study strongly supports the reliability of present cluster mass estimates derived from X-ray analyses and/or (appropriate) optical analyses.