During viral and bacterial infections, the innate immune system recognizes various types of pathogen-associated molecular patterns (PAMPs), such as nucleic acids, via a series of membrane-bound or cytosolic pattern-recognition receptors. These include Toll-like receptors (TLRs), RIG-I-like receptors (RLRs), AIM2-like receptors (ALRs), and cytosolic DNA sensors. The binding of PAMPs to these receptors triggers the production of type I interferon (IFN) and inflammatory cytokines. Type I IFN induces the expression of interferon stimulated genes (ISGs), which protect surrounding cells from infection. Some ISGs are nucleic acids-binding proteins that bind viral nucleic acids and suppress their replication. As nucleic acids are essential components that store and transmit genetic information in every species, infectious pathogens have developed systems to escape from the host nucleic acid recognition system. Host cells also have their own nucleic acids that are frequently released to the extracellular milieu or the cytoplasm during cell death or stress responses, which, if able to bind pattern-recognition receptors, would induce autoimmunity and inflammation. Therefore, host cells have acquired mechanisms to protect themselves from contact with their own nucleic acids. In this review, we describe recent research progress into the nucleic acid recognition mechanism and the molecular bases of discrimination between self and non-self-nucleic acids.