In cases where you're using Bonjour to connect over a local network, or using a hostname or IP address to connect to a local computer or to a computer over the Internet, there are several causes to check for:
Is the remote computer configured correctly to allow the incoming connection? Consult Share Screens Via a Bonjour or a Direct Connection (p. 23).
Could the remote computer be in sleep mode when you're trying to connect? See Sleep Causes Lack of Access, ahead a few pages.
If you're connecting via VNC to a remote Mac, have you turned on the special Screen Sharing option or correctly enabled VNC server software? Read Turn on VNC Service (p. 41).
If you're not using Bonjour, is the remote computer's network router configured correctly to allow the incoming connection? See Configure Your Router or Gateway (p. 66).
Is a firewall on the remote computer or remote network blocking access? Refer to Firewall Blocks Access, next page.