Goa to Hampi is a very sought after route, however the train connections are few and a bit scattered.
Goa to Hampi by Train: If you are looking for a train connection , opt for the Howrah Express (Train No:18048 , Tuesdays,Thursdays,Fridays and Sundays ).This train leaves Vasco Da Gama (VSG) by 7.10 am and reaches Hospet by 14:55 in the afternoon. Get down at Hospet Jn. This is the nearest railway station for Hampi.
Vasco Da Gama -> Madgaon -> Sanverdam Chuch -> Kulem -> Castle Rock -> Londa Jn -> Dharwar -> Hubli Jn -> Gadag Jn -> Koppal -> Hospet Jn (getdown at Hospet for Hampi)
The return train to Vasco da Gama from Hospet (Train No:18047, Amaravati Express) operates on Monday,Wednesday,Thursday and Saturdays. Leaves Hospet at 6.30am and reaches Vasco by 3pm the same day.
Another train option is to travel to Hubli Junction (UBL) from Goa and look for a connection train to Hospet.
Check out if the combination of Vasco-Hubli-Bangalore Express (Train No: 02779) and the Hubli-Hospet-Vijayawada Passenger (Train No:56502) works out for you. It needs midnight train change at Hubli. The good thing is the passenger train too has sleeper (SL) class coaches that you can reserve in advance. The Vasco-Hubli and Hubli-Hospet ticket costs would be around Rs200 and Rs 100 , both in SL Class.
See the other trains in the Hubli-Hospet-Guntakal route.
Goa to Hampi by Bus: There are also some overnight bus options from Goa to Hospet. Paulo Travels operates daily sleeper bus service from Goa to Hampi. Bus tickets costs approx Rs600.
See also how to reach Hampi from other parts of the country.
One last point between the bus and train journeys between Hampi and Goa. You can enjoy the Western Ghats sights as the train winds its way through forest. You can even spot the Dudhsagar waterfalls on your right. This is where the Mandovi River (the river you've seen in Goa) makes a 310 metres (1017 feet) fall in the thick of the forest. You'll miss this if you travel by bus! You'll miss this sight if you travel by a night train as well!