In this paper we provide the criteria for any generally covariant, parity preserving, and torsion free theory of gravity to possess a stable de Sitter (dS) or anti-de Sitter (AdS) background. By stability we mean the absence of tachyonic or ghost-like states in the perturbative spectrum that can lead to classical instabilities and violation of quantum unitarity. While we find that the usual suspects, the F (R) and F (G) theories, can indeed possess consistent (A)dS backgrounds, G being the Gauss-Bonnet term, another interesting class of theories, string-inspired infinite derivative gravity, can also be consistent around such curved vacuum solutions. Our study should not only be relevant for quantum gravity and early universe cosmology involving ultraviolet physics, but also for modifications of gravity in the infra-red sector vying to replace dark energy.