Drilling and drainage can affect movement of air flow in goaf, thus leading to changes in goaf flow field, and increasing air leakage in goaf. At the same time, there is a state of negative pressure around the borehole, and the air leakage and air flow are constantly replenishing around the drilling. The coal body in goaf presents a state of oxidation and temperature rise in the area where the air leakage is concentrated, so there is a problem of spontaneous combustion of residual coal in goaf. For the above problem, the optimal nitrogen injection for fire prevention scheme in goaf under the condition of drilling drainage was studied. The 10201 working face of Bailongshan Coal Mine was used as the background for goaf simulation by numerical simulation software. The distribution of flow field and temperature field in goaf under different drainage parameters is analyzed, and the optimal nitrogen injection condition was determined according to the reasonable drilling parameters.The results show that the gas drainage effect is good when drainage pressure is 30 kPa, and the increase of the oxidation temperature rise zone is relatively low; the drainage effect is good and the engineering amount is low when drilling interval is 6 m; when the distance between working surface and intake side nitrogen injection port is 75 m and the nitrogen injection flow is 1 500 m3/h, the width of oxidation temperature rise zone can be reduced and the cost can be saved. The actual application results show that the gas volume fractions of fully mechanized working face and the upper corner are effectively controlled, both of which are lower than 1%; the CO volume fraction of extraction pipe and upper corner is lower than 0.040% and 0.032% respectively,no spontaneous combustion occurred in the goaf, and gas drainage and nitrogen injection in the goaf achieved good application results.