To stream media files your Mac should be able to connect to the device you want to stream to and communicate with it. The receiving device should be able to communicate with your Mac, too. Some router settings may prevent communication and lead to media streaming failure.
Check your router settings for the following points:
Make sure that you have the latest firmware update for your router on the manufacturer’s website.
If you have a dual-band router, use separate names for the 2.4GHz and 5Ghz networks. Check out that both the Mac and the TV are connected to the same network. E.g. if your Mac computer is on 2.4Ghz, the receiving device should also be on 2.4Ghz.
In case your router has MAC address filtering, add the MAC address of the receiving device to the list of filtered devices.
Disable Access Point/Client isolation on your router.
Disable IGMP Proxy on your router.
Disable any Virtual Private Networks (VPNs) or proxy servers on your router and/or computer.
Enable UPnP/Multicast on your router.
Enable IGMP on your router.