The Transport Accident Investigation Commission has opened an inquiry into the train derailment in Auckland earlier today.
A KiwiRail locomotive came off the tracks and rolled on its side while travelling between the port and Westfield at about 1.30am.
Two of the three crew suffered minor injuries.
KiwiRail acting chief executive David Gordon told Checkpoint those injured were doing OK.
"[They are] a bit banged and bruised, feeling a bit sore and probably feeling a bit shaken thinking about what might have been."
The train had delivered some wagons and was travelling back, crossing from one line to another when it came off the track, he said.
"What happened is actually pretty rare, locos do come off the rails but they tend to stay upright but on this occasion it both came off and then fell on it's side, which is obviously the most concerning part of the incident."
Like planes, locomotives had a black box and that information would be provided to the regulatory authorities, Gordon said.
The track would also be checked to see if something on caused the train to come off, or whether there was some kind of mechanical failure.
"Clearly something has gone wrong and we have to get to the bottom of what it is."
The commission says the investigation will focus on the circumstances and causes of the accident with a view to avoiding similar accidents in the future, rather than to apportion blame.
Two investigators will examine the locomotive, including its history, performance and maintenance.
The weather and safety systems will also be looked at.
https://www.rnz.co.nz/national/programmes/checkpoint/audio/2018844300/how-kiwirail-s-train-shunter-derailed-in-auckland 'Clearly something has gone wrong and we have to get to the bottom of what it is' - KiwiRail acting chief executive David Gordon