A man has been sentenced to six months in prison after being found with an explosive device at Wollongong train station.

Lindsay Harris, 35, appeared in Wollongong Local Court today charged with possessing an explosive device at the station last Thursday.

He was travelling between Cringila and Wollongong when he was stopped onboard the train by police officers for not having a valid ticket.

Officers found the device after searching his backpack and finding a red container filled with railway detonators labelled 'danger explosives' with a fuse protruding from the top.

A small quantity of the drug methylamphetamine was also found in Harris' bag.

His lawyers told the court the 35-year-old had struggled with homelessness and had previously lived in a tent for two years.

In sentencing, Magistrate Michael Stoddart said the incident was particularly alarming because it occurred during peak hour at the busy station.

Magistrate Stoddart said the consequences of an explosive device being detonated at the station at that time would be devastating.

He also pointed to the fact that he admitted to previously using an explosive device to start a fire, but that he was too afraid to use this one.

The court also heard Harris was on bail for an affray charge at the time of his arrest and had failed to report to police since mid-May.

The magistrate told Harris the maximum penalty was five years in prison, however sentenced him to a fixed term of six months.

He received a reduction in his sentence for entering a guilty plea.

Harris is due to be released in February next year.