Hydrogen has the potential to become a powerful energy vector with different applications in many sectors (industrial, residential, transportation and other applications) as it offers a clean, sustainable, and flexible alternative. Hydrogen trains use compressed hydrogen as fuel to generate electricity using a hybrid system (combining fuel cell and batteries) to power traction motors and auxiliaries. This hydrogen trains are fuelled with hydrogen at the central train depot, like diesel locomotives. The main goal of this paper is to perform a techno-economic analysis for a hydrogen refuelling stations using on-site production, based on PEM electrolyser technology in order to supply hydrogen to a 20 hydrogen-powered trains captive fleet. A sensitivity analysis on the main parameters will be performed as well, in order to acquire the knowledge required to take any decisions on implementation regarding electricity cost, hydrogen selling price, number of operation hours and number of trains for the captive fleet.The main methodology considers the evaluation of the project based on the Net Present Value calculation and the sensitivity analysis through standard method using Oracle Crystal Ball. The main result shows that the use of hydrogen as an alternative fuel for trains is a sustainable and profitable solution from the economic, environmental and safety points of view.The economic analysis concludes with the need to negotiate an electricity cost lower than 50 €/MWh, in order to be able to establish the hydrogen selling price at a rate higher than 4.5€/kg. The number of operating hours should be higher than 4800 h per year, and the electrolyser system capacity (or hydrogen refuelling station capacity) should be greater than 3.5 MW in order to reach a Net Present Value of 7,115,391 € with a Return of Investment set to 9 years. The result of the multiparametric sensitivity analysis for the Net Present Value (NPV) shows an 85.6% certainty that the project will have a positive result (i.e. profitability) (NPV> 0). The two main variables with the largest impact on Net Present Value are the electrolyser capacity (or hydrogen refuelling station capacity) and the hydrogen selling price. Moreover, a margin of improvement (higher NPV) could be reached with the monetization of the heat, oxygen by-product and CO2 emission reduction.