Abstract The photon energies of molecules falling rightly into the terahertz region offers a high potential for gas detection. However, detecting gas at low concentration is difficult because of the weak dipole moments of gas in the terahertz region. Here, a unique structure of porous core photonic crystal fiber (PCF) sensor with a high sensitivity for gas detection is proposed. The dependences of the mode field distribution and the propagation loss of PCF sensor on the porosity are studied to optimize for a higher sensitivity. For the optimal PCF with a porosity of 50%, the mode field is strongly confined in the air holes in the core, and the propagation loss can reach as low as 0.013 dB/m. The detection of a toxic gas (hydrogen cyanide) is also investigated to demonstrate the sensing performance of the proposed PCF. A low concentration of 2 ppm under the standard atmosphere pressure (1 atm) can be detected based on the resonance frequency of the hydrogen cyanide. The length of the proposed PCF is just 100 mm, which is much shorter than the traditional optical fiber with several meters long. Our results provide a novel approach for the detection of toxic gas in air pollution monitoring using terahertz spectroscopy.