Cervical spondylotic myelopathy (CSM) refers to a chronic injury of the cervical cord caused by cervical intervertebral disc degeneration. Endoplasmic reticulum (ER) homeostasis is essential to counteract neuronal apoptosis. ER stress, an integral part of ER homeostasis, was observed in a rat model of chronic cervical cord compression in our previous study. However, the correlation between ER homeostasis and CSM remains unknown. The antioxidant melatonin is known to exert therapeutic effects in acute spinal cord injury, but the specific effects and their potential mechanisms in the pathological processes of CSM require further exploration. The present study hypothesized that ER homeostasis is essential for neuronal apoptosis in the CSM and that melatonin maintains this homeostasis. The results showed that ER stress led to neuronal apoptosis in rats with chronic cervical cord compression. Conversely, melatonin attenuates protein kinase R‐like ER kinase‐eukaryotic initiation factor 2α‐C/EBP‐homologous protein, inositol‐requiring enzyme 1, and transcription factor 6 signaling pathways to release ER stress and prevents Bax translocation to the mitochondrion, thereby promoting motor recovery and protecting neurons in vivo. It also rescued primary rat cortical neurons from ER stress‐induced glutamate toxicity in vitro. Moreover, melatonin remodels the ER morphology and restores homeostasis via ER‐phagy in injured neurons. FAM134B, CCPG1, RTN3, and Sec. 62 are four known ER‐phagy receptors. In this study, Sec. 62 was identified as a key melatonin factor in promoting ER‐phagy and restoring ER homeostasis in damaged neurons in vivo and in vitro. In conclusion, melatonin suppresses neuronal apoptosis by reducing ER stress and promoting ER‐phagy to restore ER morphology and homeostasis. The current results suggested that melatonin is a promising treatment for CSM owing to its restorative effect on ER homeostasis; however, well‐designed randomized controlled trials must be carried out to further investigate its clinical effects.