In northwest China, changes in cultivation patterns and the scarcity of preferred hosts have forced Helicoverpa armigera to feed on the marginal host walnut (Juglans regia). However, the mechanisms allowing this adaptation remain poorly understood. Here, we investigated the behavioral, physiological, and molecular mechanisms underlying the local adaptation of this pest to walnut fruits. Compared to the kernel, the green husk and shell generally contained higher levels of phytochemicals and had greater impact on larval feeding preference, fitness, and cytochrome P450 activity. These negative effects were further supported by a larger number of upregulated detoxification genes in insects fed green husks or shells based on transcriptome sequencing. Together, these data suggest that P450 genes (such as LOC110371778) may be crucial to H. armigera adaptation to the phytochemicals of walnuts. Our findings provide significant insight into the adaptation of cotton bollworm to walnut, an alternative host of lower quality.