Thermite welding of rails is the only technology that allows connecting rails in hard-to-reach places such as turnouts and bridges. Experience in operating thermite welded joints shows that this type of welding is characterized mainly by casting defects. It is known that casting defects depend on the thermal processes occurring during rail welding. This article presents the results of modeling the heat transfer process of thermite welding of rails. The simulation was carried out using the LVMFlow software product. 3D heat transfer models of the “casting mold – weld – rail” system have been developed, considering phase transitions. Based on the proposed models, thermograms of the distribution of temperature fields are presented both over the cross section of the welded joint and along the length of the welded joint.