The invention discloses a power cabinet with a fire extinguishing function, comprising a cabinet body, an electromagnet, a sleeve, a first movable rod, a second movable rod, a first wedging block, a second wedging block, a fixed plate, and a guide column and movable plate; when a fire occurs inside the cabinet, the electromagnet is energized through the action of the temperature sensor and the smoke sensor, and the second wedge-shaped block and the first wedge-shaped block are separated from each other through the attraction of the electromagnet to the iron block. At this time, due to the effect of the first coil spring, the movable plate moves down and resets. At this time, the first cooling hole and the second cooling hole no longer overlap, so that the outside air enters the cabinet, and at the same time the solenoid valve is opened, then The nitrogen in the nitrogen tank enters the cabinet, thereby reducing the oxygen in the cabinet rapidly, which has the effect of quickly extinguishing the fire. When the cabinet returns to normal, pull the movable plate upwards, and the first heat dissipation hole and the second heat dissipation hole overlap at this time , It is convenient for the usual ventilation inside the cabinet, and the operation is simple and fast.