Search code examples
windowsdronekit-pythondronekit

Dronekit-sitl fails to bind on default port 5760


I have dronekit-sitl installed in a python3 virtual environment on my Windows 10 machine and have used it before by running dronekit-sitl copter with no issues. However, as of today I am running across what seems to be a permission issue when trying to execute the ArduCopter sitl.

$ dronekit-sitl copter
os: win, apm: copter, release: stable
SITL already Downloaded and Extracted.
Ready to boot.
Execute: C:\Users\kyrlon\.dronekit\sitl\copter-3.3\apm.exe --home=-35.363261,149.165230,584,353 --model=quad -I 0
SITL-0> Started model quad at -35.363261,149.165230,584,353 at speed 1.0
SITL-0.stderr> bind port 5760 for 0
Starting sketch 'ArduCopter'
bind failed on port 5760 - Operation not permitted
Starting SITL input

Not sure what might have triggered a new operation permission issue, and I tried to start over with a fresh Python environment, but even after a complete PC shutdown, I am still having the error as shown above.


Solution

  • It turns out that having docker on my system was the culprit and excluding the port I was attempting to use as mentioned in this SO post that led me to this github issue. Running the command in an elevated terminal:

    netsh interface ipv4 show excludedportrange protocol=tcp
    

    Provided me the results of the following excluded ports:

    Protocol tcp Port Exclusion Ranges
    
    Start Port    End Port
    ----------    --------
          1496        1595
          1658        1757
          1758        1857
          1858        1957
          1958        2057
          2058        2157
          2180        2279
          2280        2379
          2380        2479
          2480        2579
          2702        2801
          2802        2901
          2902        3001
          3002        3101
          3102        3201
          3202        3301
          3390        3489
          3490        3589
          3590        3689
          3693        3792
          3793        3892
          3893        3992
          3993        4092
          4093        4192
          4193        4292
          4293        4392
          4393        4492
          4493        4592
          4593        4692
          4768        4867
          4868        4967
          5041        5140
          5141        5240
          5241        5340
          5357        5357
          5358        5457
          5458        5557
          5558        5657
          5700        5700
          5701        5800
          8005        8005
          8884        8884
         15202       15301
         15302       15401
         15402       15501
         15502       15601
         15602       15701
         15702       15801
         15802       15901
         15902       16001
         16002       16101
         16102       16201
         16202       16301
         16302       16401
         16402       16501
         16502       16601
         16602       16701
         16702       16801
         16802       16901
         16993       17092
         17093       17192
         50000       50059     *
    
    * - Administered port exclusions.
    

    Turns out that docker or possibly Hyper-V excluded the range that included 5760:

    5701        5800
    

    And as mentioned from the github issue, I probably resolved this issue before after a set number of restarts that incremented the port ranges, or possibly got lucky in the past starting dronekit-sitl before docker ran on my system. Either way, to resolve this issue of Operation not permitted, running the command as admin:

    net stop winnat
    net start winnat
    

    solved the issue with dronekit-sitl without having to specify a different port besides the default 5760.