The esters are the most important flavor components in Baijiu as their species and content decide the style of Baijiu. During the formation of esters, pits play important roles. In this study, the main esters and their related microorganisms in different years of pits (5, 35 and 100 years) of strong-flavor Baijiu were comprehensively researched by headspace solid-phase microextraction gas chromatography mass spectrometry (HS-SPME-GC-MS) and amplicon sequencing. A total of 690 bacterial genera and 155 fungal genera were detected. The microbial composition of ZPs (fermented grains) from 100 years pit was the most abundant at the genus level. A total of 177 volatile flavor components were observed, including 80 esters, 42 alcohols, 21 acids, 10 ketones and 11 aldehydes. Ethyl acetate was the lowest and ethyl caproate was relatively high in 100 years pit. 15 genera, including