Motivated by the apparently conflicting results reported in the literature on the effect of environment on nuclear activity, we have carried out a new analysis by comparing the fraction of galaxies hosting active galactic nuclei (AGNs) in the most overdense regions (rich galaxy clusters) and the most underdense ones (voids) in the local universe. Exploiting the classical BPT diagnostics, we have extracted volume limited samples of star forming and AGN galaxies. We find that, at variance with star-forming galaxies, AGN galaxies have similar distributions of specific star formation rates and of galactic ages (as indicated by the Dn4000 parameter) both in clusters and in voids. In both environments galaxies hosting AGNs are generally old, with low star formation activity. The AGN fraction increases faster with stellar mass in clusters than in voids, especially above 1010.2 M⊙. Our results indicate that, in the local universe, the nuclear activity correlates with stellar mass and galaxy morphology and is weakly, if at all, affected by the local galaxy density.