Zhou Xingbai, 29, from Tongren city in southwest China's Guizhou province, became a migrant worker in 2006 when he finished middle school, police said.
He has allegedly been addicted to online gambling since 2014, squandering his savings and living in heavy debt.
Zhou wrote on his WeChat account that he owed many people money, and was going to do something "very crazy," which would definitely cost his life, state-run Xinhua news agency said.
At Shanghai Pudong International Airport, he allegedly threw a homemade explosive device in beer bottle at a check-in counter in Terminal 2 in the afternoon yesterday.
Also Read
Police found explosive used to make firecrackers in Zhou's house.
Four passengers, including a Philippine national, were injured by flying glass, and a few flights were affected.
Zhou cut his own throat with a knife at the airport, but was taken to hospital for medical treatment.