Noise is an important environmental risk factor for physical and mental health. Furthermore, long-term noise exposure is burdensome for the mind and body and has become a serious problem. Rail transportation is one of the main methods used to transport goods in China; however, the noise and vibrations generated by freight trains have serious impacts on residents in nearby regions. To further investigate the relationship between railway noise and road noise exposure and changes in sleep duration and mental health scores, a field study in Harbin, China, was conducted and a health risk prediction model was constructed. The results showed that for every 1 dB increase in the Equivalent continuous A-weighted sound pressure level (LAeq), the percentage of deep sleep among residents living near the railway decreased by 0.2 %. Although residents near the railway reported similar sleep evaluations compared to those living farther away, they exhibited poorer mental health. Cox risk modeling indicates that the risk of mental health problems is approximately three times higher for those living near the railway. These findings potentially provide benefits in developing strategies to reduce the risk of mental illness for people residing near railways.