I have Sony's XBR55X810C Android TV. Trying to cast from my Android tablet's YouTube would fail frequently. Recently, I wrote to support and they asked me to checkout this link. For some reason, even though the TV was set for auto update, it didn't update Google Cast. I did as per the link and I haven't faced the issue for the last 1 week.
Edit: Looks like the problem is back for me. I got the "cannot connect message" in Android Youtube app couple of times in the last 2-3 hours. It went away only after rebooting the TV.
Yup, the latest Google Cast update has made it flawless. I casted a tab for several hours without any issues.