Chronic pain affects hundreds of millions of people world-wide and current therapies do not adequately address pain for most patients. To identify core regulators of pain perception we combine functional screening in fruit flies with human exome sequencing of extreme pain patients. From this, we identified SETDB2, a histone H3K9 trimethylase, as a core regulator of pain perception and a new cause of congenital insensitivity to pain (CIP). We generated SETDB2 knockouts and humanized SETDB2 CIP point mutation mice, and both strains lack pain perception but are otherwise normal. Mechanistically, SETDB2 mutations result in the ectopic expression of muscle proteins in sensory neurons, and forced expression of muscle factors was sufficient to block pain perception. Our data suggest that SETDB2 provides epigenetic insulation to maintain sensory neuron fate. While enhancing histone methylation may specifically help SETDB2 CIP patients, targeting SETDB2 could be a new non-additive therapy for millions of people suffering from chronic pain.