You have to open up certain ports to allow the data to go through. You can't just turn off your firewall, that won't open the ports. Search on Google for the ports Terraria needs open then open them on your firewall. If you have another firewall then you have to open them up on that one as well. Most antiviruses come with a firewall as well so you'll most likely have to do that.