To fix this, make sure you're using Steam or GOG to play the game. This can also occur if you're behind a firewall that directly blocks connections to gaming addresses. Check your firewall settings to make sure Stardew Valley and other gaming services like Steam or GOG aren't blocked.