Objective To explore the inhibitory effect of sodium ferulate (SF) on the inflammatory response in migraine rats by regulating the c-Jun N-terminal kinase (JNK)/p38 mitogen-activated protein kinase (p38 MAPK) signaling pathway. Methods The migraine rat model was prepared by intraperitoneal injection of nitroglycerin. After successful modeling, the rats were randomly grouped into model group, SF low dose (SF-L) group (50 mg/kg), SF high dose (SF-H) group (100 mg/kg), SF+JNK inhibitor (SF + SP600125) group (SF 100 mg/kg +SP600125 10 mg/kg), and SF+JNK activator[SF + anisomycin(AN) group (SF 100 mg/kg +AN 5 mg/kg), 12 in each group, another 12 SD rats without treatment were taken as blank group. The behavioral changes of the rats in each group were observed 24 hours after the administration, the levels of 5-hydroxytryptamine (5-HT), nitric oxide (NO), tumor necrosis factor-α (TNF-α) and interleukin-6 (IL-6) in serum were detected by ELISA, the neuronal apoptosis in brain tissue was observed by TUNEL staining, immunohistochemistry was used to evaluate the expressions of TNF-α, IL-6 and calcitonin gene-related peptide (CGRP) in brain tissue, Western blotting was used to detect the expressions of JNK/p38 MAPK pathway-related proteins in brain tissue. Results Compared with the blank group, the number of times of scratching the head and climbing the cage of the rats in the model group increased significantly, and the apoptosis rate of neurons increased significantly; the content of 5-HT in serum decreased significantly, and the levels of NO, TNF-α and IL-6 increased significantly; the expressions of TNF-α, IL-6 and CGRP, and the ratios of phosphorylated JNK (p-JNK)/JNK and phosphorylated p38 MAPK(p-p38 MAPK)/p38 MAPK in brain tissue obviously increased (all P<0.05). Compared with the model group, the number of times of scratching the head and the times of climbing the cage of the rats in the SF-L group and the SF-H group reduced significantly, and the neuron apoptosis rate reduced significantly; the content of 5-HT in serum increased significantly, and the levels of NO, TNF-α and IL-6 decreased significantly; the expressions of TNF-α, IL-6 and CGRP, and the ratios of p-JNK/JNK and p-p38 MAPK/p38 MAPK in brain tissue obviously decreased (all P<0.05). Compared with SF-H group, the protective effect of SF on migraine rats in SF+SP600125 group enhanced significantly; the protective effect of SF on migraine rats in the SF+AN group reversed significantly. Conclusion SF may inhibit the expression of JNK/p38 MAPK signaling pathway, effectively inhibit neurogenic inflammatory response in migraine rats, reduce neuronal apoptosis, and achieve a protective effect on migraine rats.