Upvote:7
The free train between terminal 4 and 2/3 is part of TfL Rail's Heathrow-Paddington line. Some services go only to terminal 2/3; others continue to Paddington (and are not free except for the bit between terminals 4 and 2/3).
They run from roughly 5 AM to midnight on most days; 6 AM to midnight on Sundays.
If you're transiting, you probably won't want the train (which is landside of immigration), but the interterminal airside transfer buses, though.