An Indonesian man who used his bare hands to kill a snake on a busy train in Jakarta was hailed as an internet hero.

The man who was not named and was seen wearing glasses and a backpack on the train from Bogor to the capital, Jakarta on Nov.21, grabbed the snake as it slithered on the overhead compartment of the train.

According to AFP, the train made an emergency stop after the reptile was spotted lurking on the baggage rack. Smartphone footage of the incident showed the man casually pick up the snake's by its tail and then smash its head on the floor in a whipping motion.

The snake immediately died following the man’s actions and was then seen being tossed out of the train to security staff as shocked spectators, including a man identified as a baton-wielding transit security officer gave the man wide berth.

Many users on social media called the man brave and heroic after videos of the incident went viral. 

The snake appeared to be almost three feet long. However, it was not clear what kind of a serpent it was and if it was venomous. No injuries to passengers were reported.

Indonesian news publication detikNews cited train operator PT Kereta Commuter Indonesia (KCI) saying the reptile was thought to have slithered out from a passenger's bag, however, it was difficult to detect which passenger it was.

They also apologized to the passengers and said: "We regret the incident and apologise to train travellers who were disturbed by it," spokeswoman Eva Chairunnisa told AFP.

Indonesian newspaper Jakarta Globe reported that the Directorate General of Railways at the Ministry of Transportation had launched an investigation into the circumstances surrounding the discovery of the snake.

"The discovery of a snake inside a railcar on the Bogor-Angke line caused passengers to panic, so the train had to stop at Manggarai Station [in Central Jakarta]... to prevent a potential accident resulting from the panic," the directorate general said in a statement on Wednesday.