Short answer: casting needs your phone and the TV, Chromecast or speaker to be able to reach each other on the same network. Apple says to connect your iPhone or iPad to the same Wi-Fi network as the AirPlay device. Google’s help for Cast audio devices says to use the same network name and to turn off AP (client) isolation on the router.

Google’s network guidance quoted here comes from its help for Cast audio devices and speakers; Apple’s covers AirPlay TVs and speakers. If the TV or speaker can’t get online at all, that’s a different problem: start with can’t connect to Wi-Fi.

Check 1: are both on the same network name?

Look at the Wi-Fi name your phone is using, then the one in the TV’s or speaker’s network settings. Google’s guidance for Cast audio devices on Android says the phone and the Cast device should be on the same wireless network name (SSID). For AirPlay, Apple says to connect your device to the same Wi-Fi network as your Apple TV, AirPlay-compatible smart TV or Mac.

Check 2: is isolation turned on?

Google says AP isolation, also known as client isolation, must be turned off on the router, and that guest, hotel or public networks with isolation will prevent setup. Google’s page is written for Chromecast Audio and Cast speakers set up from Android; it is the Google guidance this article relies on.

Check 3: AirPlay settings

For AirPlay, Apple’s checklist is to keep the devices on and near each other, update them, check they’re on the same Wi-Fi network, make sure AirPlay receiving is allowed, and restart them. If the TV or speaker was set up in the Home app, Apple says Home settings can restrict AirPlay; check Home Settings > Speakers & TV.

Fixing it without undoing your setup