During the design and implementation of underground constructions, the risk assessment and management of geological hazards are important due to the hazards such as the water inflow, collision with crushed fault zones, squeezing and instability around excavation zones. In the present research, it is attempted to study and assess the risk of geological hazards in 378+021 km of the route of Ardabil-Mianeh railway tunnel using the harmony search algorithm (HSA). In the first section of research, after studying structural and geological characteristics during 24 sections of the excavation route, the risk relating to geological hazards including the tunnel instability, squeezing, water inflow and swelling was assessed in three separate classes using HSA. In order to study the accuracy of results, geological hazards recorded during the implementation of excavation operations were used. Studies obtained from the comparison of observed and predicted results indicate the high accuracy of HSA in the assessment and prediction of geological risks in the tunnelling project.