How do I control the ports in use by SonarLint?

Each instances uses a lot of ports (see image below for the list in one instance), which end up conflicting with ports that I normally use for development. I normally have more than one instance of vscode open, which then mean more instances of SonarLint. How do I control the ports in use by SonarLint?

vscode-instider 1.62.0 (Commit bcb9df5afa52c5b713f62e86dcac2c5050504b5f) on Windows 10
SonarLint 3.0.0
Not using connected mode

@TrevorDearham apologies for the delay in replying.

Which IDE are you using?

As far as I’m aware, SonarLint only listens on one port. The range is fixed, and each new instance will use the first free port.

1 Like

Hello @TrevorDearham,
One instance of SonarLint uses first available port in range 64120-64130 if there is at least one available. In your case I believe it’s 64123. Here is the link to the class that responsible for server.
Also you should see in logs exactly what port has been taken by current instance of SonarLint. Here you can see how to setup logs output in VSCode.
It will be the message “Started security hotspot handler on port $portNumber” if at least one port in range is available or the error message “Unable to start security hotspot handler” if whole range is taken by another apps. You can find logging code in the same class I referred above. So I don’t think list of ports in range 3297-3362 on screenshot you provided is taken by SonarLint.
I hope it helps and I’m ready to answer other questions you have.

Hello again, @TrevorDearham
The problem can be in language server that also running on separate port. If you restarted/turned off VSCode dozens of times and during restart language server didn’t properly stoped - you can get such picture.
Did you experienced something close to situation I described?

Thank you @duncanp and @Kirill_Knize for your responses.

@duncanp I’m using vscode-insider. Yes each instance only listens on one port, but opens around 65 ports, which appear to be back to itself. I’m more concerned about the 65 ports that are consuming ports I use, e.g. 3306 in the above screenshot is the default MySQL port. Also I have more than one window of vscode open and so have more than one instance of the extension open, so the number of ports being consume quickly multiplies.

@Kirill_Knize The above image is from Process Explorer looking just at the process java -jar sonarlint-ls.jar ... and so they are a reflection of all the ports being consumed by that process alone both in listening and any internal and external network connections. I see the same number of ports being consumed for each and every instance of this process all the time (first load of vscode, reload after update, etc.). These connections are permanently open, rather than changing over time.

Would you be able to open a tool that tracks network connections to check this? netstat will show them as java.exe, so the following Powershell will show you netstat -abn | select-string -Context 2 java.exe. Process Explorer makes it much more obvious that the above process is the cause and is powerful in many other ways, so I would recommend taking a look at it.

I’m now using SonarLint 3.1.0 with the same result.