There are several possible causes for this behavior.
1. Two (or more) computers on the local network have the same Bonjour name, such as "X's-MacBook-Pro.local". Resolve the name conflict by renaming one or more of them in the Sharing preference pane.
2. You have two simultaneous connections to the same local network: probably Ethernet and Wi-Fi. If applicable, disconnect the Ethernet cable or turn off Wi-Fi.
3. A Mac wakes from sleep due to network traffic. This is a bug in OS X that may only affect some models.
4. A device that gets its network address from the router wakes from sleep, and the address it was using before has been assigned to another device.
5. A third-party wireless router has incompatible settings or firmware. In that case, refer to the manufacturer or ISP for support. Restarting the router may help, temporarily.
6. See also this support article.