The Z-burst mechanism invoked to explain ultra-high energy cosmic rays is severely constrained by measurements of the cosmic gamma-ray background by EGRET. We discuss the case of optically thick sources and show that jets and hot spots of active galaxies cannot provide the optical depth required to suppress the photon flux. Other extragalactic accelerators (AGN cores and sites of gamma ray bursts), if they are optically thick, could be tested by future measurements of the secondary neutrino flux.