There is no train service in Nepal, other than an obscure branch line from India till Janakapur-Nepal, which are of limited interest to travelers.
However you can travel by train till nearest border cities in India (Gorakhpur Train staion near Sunauli border), (New Jalpaiguri Train station near Kakarvitta border), (Jogbani Railway Station near Biratnagar border), (Raxaul Railway Station near Birgunj border) and enter Nepal via private/local transport.
From China there are regular train till Lhasa and from Lhasa you have options of 7 days overland trip or an flight to Kathmandu.