Here is a way to fix Profiler error "Unable to forward traffic to device"

To help anyone who searches for this problem (which probably happens under Windows as well):

  • Build and Run your app with both “Development Build” and “Autoconnect Profiler” enabled; I know, it’ll stop with the error, but the app should be installed on the device;
  • When you see the error “Unable to forward traffic to device”, check the Editor Console to find the error; it also shows the complete command-line that Unity used when trying to connect. It looks like this:
/(some_path)/Sdk/platform-tools/adb -s "ce09160128d8321405" forward "tcp:34999" "localabstract:Unity-com.somename.someproject"
  • Copy the command you see exactly as shown (select it and CTRL+C), and then close Unity;

  • Open a terminal (on Ubuntu: CTRL+ALT+ T), and paste the same command there (on Ubuntu: CTRL+SHIFT+V). Press ENTER, of course; you should see no errors, which means that adb accepted the command now;

  • Open Unity again, and wait until it finishes loading;

  • Now manually run your app on the connected Android (do not disconnect the device from the USB cable, just run the app manually while still connected); you should see the Profiler running against your app – if not, then change the “Active Profiler” (a combobox located at the top of the Profiler window).

That is a bit annoying but you only need to do that once per session. After connected, you can rebuild as many times as you wish without having to repeat the process.

Good luck!

4 Likes

If I do this, adb gives me this:
error: cannot bind listener: cannot bind to 127.0.0.1:34999: An attempt was made to access a socket in a way forbidden by its access permissions. (10013)

Ask nicely with sudo (or from an Administrator shell in Windows).

I’m in an admin command prompt

Did you close Unity before issuing the command? You are expected to paste the command then close Unity before pressing ENTER in the terminal.

Yeah, it’s either the port already in use (by Unity and any running Android debugger) - or the firewall blocking it.

Thanks guys, that did the trick. Closed all my apps.

THANK YOU SOO MUCH FOR THIS!!! :smile:

If it was not for people such as yourself posting their solutions to issues, Unity would not be as great and accessible.

All the best.

1 Like

Hey davtam, very thank you for the kind comment!

Thanks for the info about closing unity before connecting via shell. It didn’t work otherwise!

An Oldie but a Goodie -Saved my Life - THANKS!

Is there some permanent solution to this?