Pain is a hallmark of tissue injury, inflammatory diseases, pathogen invasion and neuropathy. It is mediated by nociceptor sensory neurons that innervate the skin, joints, bones, muscles and mucosal tissues and protects organisms from noxious stimuli. Nociceptors are sensitized by inflammatory mediators produced by the immune system, including cytokines, lipid mediators and growth factors, and can also directly detect pathogens and their secreted products to produce pain during infection. Upon activation, nociceptors release neuropeptides from their terminals that potently shape the function of innate and adaptive immune cells. For some pathogens, neuron-immune interactions enhance host protection from infection, but for other pathogens, neuron-immune signalling pathways can be exploited to facilitate pathogen survival. Here, we discuss the role of nociceptor interactions with the immune system in pain and infection and how understanding these pathways could produce new approaches to treat infectious diseases and chronic pain.