Gas sensors are important in many fields such as environmental monitoring, agricultural production, public safety, and medical diagnostics. Herein, Tamm plasmon resonance in a photonic bandgap is used to develop an optical gas sensor with high performance. The structure of the proposed sensor comprises a gas cavity sandwiched between a one-dimensional porous silicon photonic crystal and an Ag layer deposited on a prism. The optimised structure of the proposed sensor achieves ultra-high sensitivity (S = 1.9×105 nm/RIU) and a low detection limit (DL = 1.4×10-7 RIU) compared to the existing gas sensor. The brilliant sensing performance and simple design of the proposed structure make our device highly suitable for use as a sensor in a variety of biomedical and industrial applications.