The shooting took place at the Santa Clara Valley Transportation Authority rail yard in San Jose on Wednesday.
Officials say the victims include transit employees and the suspect, a former employee, is also dead.
The shooting broke out at 06:45 local time (14:45GMT), transit officials say. Authorities say they are checking the scene for explosive devices.
San Jose Mayor Sam Liccardo told reporters “this is a horrific day for our city”.
“My attention will turn to ensuring this never happens again to our city.”
He added that one person succumbed to their injuries while being transported to hospital.
A local CBS station reports that the shots broke out during an employee meeting for rail workers. Just before the shooting, a fire broke out at a home belonging to a Santa Clara Valley Transportation Authority (VTA) employee, CBS reports.
According to the LA Times, the suspect may have set his home on fire before embarking on the rampage, which authorities are looking into but have not confirmed. The suspect’s age was not provided by authorities.
The shooting shut down traffic on nearby streets during the morning commute. Trains will halt service at noon local time.
Authorities said that a bomb squad is at the scene and searching for explosive devices but that there is no active threat to the public. They would not specify how many explosive devices had been found.
San Jose Sherriff’s Deputy Russell Davis emphasised that the investigation was active and ongoing. Authorities will give another update at 13:30 local time (21:30GMT).
Railway president Glenn Hendricks told reporters that the attack “‘happened on the yard but it did not happen in the operations control centre”.
California Governor Gavin Newsom tweeted: “We are in close contact with local law enforcement and monitoring this situation closely.”
Federal agents, including the FBI, are assisting in the investigation. Mayor Liccardo said he has spoken on the phone with Vice-president Kamala Harris – a Californian herself – and Transportation Secretary Pete Buttigieg.
Across the US, there have been 230 mass shootings so far this year, according to the Gun Violence Archive.
A mass shooting is defined by the group as a crime in which four or more people are fatally shot.
The Santa Clara VTA operates three train lines, making up over 40 miles (65km) of rail. They also operate about 70 bus lines in the city.
Santa Clara is the largest county in California’s Bay Area and is home to Silicon Valley – a hub for tech start-ups.
Adobe, PayPal and eBay are all based in the city of about one million residents, which is located about 50 miles southeast of San Francisco.