Hmm, the only thing I can come up with is that you accidentally told Windows not to allow Terraria to go past your firewall.
I'd check the firewall settings.
For Windows 10 ->
- Click Start
- Type 'Firewall'
- Click Windows Defender Firewall
- Click Advanced Settings
- Check the Inbound rules to see if Terraria is in there.
- If the case, right-click the Terraria rules that you can find, click Properties on each of them
- Check 'Allow the connection' and click OK; do this for each of them.
- I don't think there should be any Outbound rules, but feel free to check.