The method involves introducing inert gas or inert gaseous mixture into the pipe before filling water or vapor of boiler into gas flow of pipe. The inert gas or inert gaseous mixture is introduced during discharge of boiler water or vapor from the resulting free flow volume of the pipe. The discharge of boiler water or vapor is performed when turning off the steam boiler. The inert gas or inert gaseous mixture is introduced into pipe by opening vent valves.