We demonstrate the use of in situ SiNx preferentially deposited on the etched defect pits as a mask to block the propagation of threading dislocations (TDs). Etch pits are generated on the GaN template using the wet etching technique. The SiNx layer is then deposited on etch pits, followed by a regrown GaN layer. It turns out that a 60% reduction in TD density of the GaN epilayer is obtained compared with the conventional GaN growth method. The significant improvement is more attributed to the prevention effect by covering etch pits rather than the merging effect by reorienting the dislocation propagation.