It is not known when Hou Junji was born, and little is known about his family background other than that he was from Bin Prefecture (豳州, roughly modern Xianyang, Shaanxi).
By 626, Li Shimin was locked in an intense rivalry with his older brother Li Jiancheng the Crown Prince, and he feared that Li Jiancheng would kill him.