In many cases the firewall on your computer may be preventing the devices from communicating.
Microsoft has included instructions for allowing applications through the Windows firewall here:
If you're using a Mac, Apple has provided similar instructions here:
If you are running an anti-virus product, such as Norton, you may have to follow a similar process. This is very important as anti-virus applications often have their own firewall and network traffic blockers. It is often easier to fully disable these applications while testing for connection and then reenable and make adjustments later.
It's also possible that the firewall on your router is preventing communication. If the above steps check out, then you may need to check that your router is configured to properly allow Google Cast traffic. Most home networks will not need any special configuration, but sometimes you may need to change a setting or two on your router to allow casting on your network. The link below will includes a list of compatible routers as well as the most commonly needed configuration changes on many popular home routers.