Switched to 2020.3.3f1 -- No Debugger and UDP Error,Unable to Use UDP port for VS/Unity Messaging

Was using 2020.30f1 without issues. Windows 10, latest VS.

Switched to 2020.3.3f1 and now getting the error:

Unable to use UDP port 56670 for VS/Unity messaging.
You should check if another process is already bound to this port or if your firewall settings are compatible.

The exact port number changes when relaunched. This occurs with a new game, a game that was upgraded, and old games not on 2020.3.3f1.
Debugging in VS no longer works as will not synch up.

How eliminate the error and get VS debugging operational?

Additional info. Deleted all VS files from game. No joy. Deleted from Package Manager VS Editor and Code Editor then reinstalled. No joy. Restarted computer after each action. Still no joy. Then after numerous attempts to attach in VS, it suddenly started working. But still get the same error in game. While the game error is UDP port 56222, the VS Attach to Unity shows port 56220. Are the ports settable / selectable in either Unity or VS?

Did you ever find a solution for this problem? I ran into the same issue with 2021.1...

9 Answers

9

This solution is “dirty” as it will be overwritten with updates. Handle with care.

Ok, so with the Info of my Comment above: You can change the port Unity is using in case of a conflict.
In Visualstudio open the “VisualStudioIntegration.cs” Script. (Just click on the warning in Unity). Change in line 123 (might change in other releases) the Port number like i did. Restart VS and Unity.
Unity then uses a higher port number which (hopefully) doesn’t conflict with another.

		private static int DebuggingPort()
		{
123			return 56500 + (System.Diagnostics.Process.GetCurrentProcess().Id % 1000);
		}

That worked for me, thank !

This works, though to persist, you need to restrict your user of writing into the file (after your edit): otherwise unity will keep overwriting it from the package upon reloading the project. For that, right click on the file, properties > security > click Edit and in "Permissions for [user]" check the Deny checkbox after Write > apply. Yeah, this manure wasted a lot of my time.

Any solution to this one?

Ok, I tried this, with version 2020.3.20f1, in my file the port number was 56000, changed it to 56500, saved it, and ran it and … it changed back. Quit Unity Editor, changed it again, reloaded, it changed back.

So it didn’t work - I guess.

Except here is the wierd thing. The error message “Unable to use UDP port 56214 for VS/Unity messaging” went away. So maybe it did work in some strange inscurtable way?

I don’t know. This behavior is flaky but it is probably some flaky Windows-Unity Interaction.

Nothing weird about it. The UDP port number is that constant number, plus the process id of the editor. The process id is assigned by the OS when the process starts, so it will likely be different every time. What really should be done here is they should check if the requested port is in use, and if it is, modify the number and try again. I'm not sure why they aren't doing that here, but the workaround on the user side is to restart Unity so it gets a different process id, and therefore requests a different UDP port.

Same problem, Unity 2021.2.7f1 on Windows 11 (I know, I'm a crazy risk taker). Made Mike's change to "VisualStudioIntegration.cs" Script, it automatically changed back after Unity compiled and warned that the file shouldn't be changed... yet the problem went away for now.

Here is something interesting… I was dealing with this issue today and was almost done (typing up a big this stinks message) I am on 2021.2.12f1/Windows 10 (full patches) and VS 2019/2022 I kept getting this error even after setting all the firewalls and monitoring it with TCPView (systernals) and could not find any reason why this wasn’t working… I reinstalled VS and the unity tools… then I went to my window/package manager and uninstalled the visual studio editor package and noticed that the visual studio code editor package was also installed… removed both reinstalled just the visual studio editor and like magic the message is now gone.

Blah, never mind.... open and closed it again, got the same error... and even when I don't get the error Visual studio wont connect anyways giving that "unspecified error"

I finally figured out what was causing it, apparently it was vmware, after uninstalling it everything works.

For me, I'm on Unity 2021.3.2f1. All I need to do is to disable all the Windows Firewall rules related to "Unity" (Unity Hub, Unity 2020.3.20f1 Editor, Unity 2021.3.2f1 Editor, etc.), even if the rules themselves are all allowing the connections to go through. This, paired with Microsoft SysInternals TcpViewer and Resource Monitor on Windows 10 x64 Pro, I was able to confirm Unity no longer shows the warning messages.

I solved it by deleting the rules for the unity hub in the firewall. The rules were re-created at the unity hub startup and the problem was solved

@asperatology said remove Windows Firewall rules to Unity Hub and then re-allow Unity Hub when it launches again. Worked for me this time around. More info: In WIndows Defender Firewall click "Allow an app or feature through...", I deleted the Private/Public Unity Hub items and they rebuild on the next Hub launch.

I think I have potential solution.

During the day I enabled Intel Virtualization Technology in BIOS and I got same issue (warning). I disabled it and now it works without warning.

I run Unity version 2021.3.13f1 (LTS) on Windows 10 pro.

Instructions to BIOS:

My Solution:
Disabled vEthernet(Default Switch) in network.

  1. This issue occurs after I uninstalled VMWare. The vEthernet connection is created by VMWare but not be removed anyhow.
  2. The Unity projects created before VMWare uninstalling have the similar issue.

So I tried to disable the virtual switch and it works.

@the_Whizzkid’s changing port in VisualStudioIntegration.cs doesn’t work for me.

Try to create rules for the Windows Firewall: allow all outgoing and incoming connections for the Unity and the Visual Studio applications. In Windows you can find them here:

C:\Program Files\Unity\Hub\Editor\2022.3.10f1\Editor\Unity.exe
C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe

I just went to Windows Defender Firewall, advanced settings, and created a new Incoming Rule for that UDP port. I don’t know if port will change and error will come again… but now it works.

It worked, thank you

Raising visibility to @justingmp’s and @geronimo_desenvolvimentos’ comments:

I had both VMware and VirtualBox, and uninstalling both of them solved both the unable to use UDP port for vs/unity messaging and the unable to join player connection multicast group issues.