I'm unable to forward a port

Hi, I just tried to forward a port; and I’m getting the following:

Could it be something on my side?

Thanks!

10 Likes

same

1 Like

same

1 Like

Yes this is broken for me as well, but it works in VSCode

Still not working for me :confused:

1 Like

The problem is that the exe used for tunneling does not exist for Cursor in
C:\Users\username\AppData\Local\Programs\cursor\bin

I got around this problem by copying the bin folder from VS Code to Cursor.

Be aware tho’, closing the port from Cursor does not stop the process and the forwarding stays active, you have to manually stop code-tunnel.exe eg. from task manager.

4 Likes

this worked for me. thank you!

getting same issue

Hey, currently the code-tunnel functionality, which powers this feature, is not available in Cursor as it is proprietary to VSCode.

I’ve added this to our internal feedback tracker to see if we can ship an alternative method to get this functionality to work in a future release.

3 Likes

Some suggestions in light of that: remove the button, or pop up a message to your sentiments when you press the button, add some docs around it, etc.

Being that this is a VSCode fork, I expect for this to work, so if it doesn’t, not expressing that is somewhat false advertising?

1 Like

More than a year, and we have the same issue.. Can’t believe

5 Likes

A very easy fix that is taking years to be addressed.

For the Cursor dev team:

Replace “code” by “cursor” in this line. Done.

1 Like

How after all this time this is not fixed yet

With the help of cursor agent I got the below tasks.json that you put in your .vscode folder in cursor root of your project; I don’t know why it needs this complex embedded powershelll script but it works. This one forwards port 8765 for foxglove robotics simulation visualization.

Method 1: Using Cursor Tasks (Recommended) :white_check_mark:

  1. Press Ctrl+Shift+P (or Cmd+Shift+P on Mac)

  2. Type “Tasks: Run Task”

  3. Select “Forward WSL Port 8765 (Foxglove)”

  4. You may need to enter your Windows admin password

Note: The task automatically bypasses PowerShell execution policy.

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Forward WSL Port 8765 (Foxglove)",
            "type": "process",
            "command": "powershell.exe",
            "args": [
                "-ExecutionPolicy",
                "Bypass",
                "-NoProfile",
                "-Command",
                "Write-Host 'Requesting Administrator privileges...' -ForegroundColor Yellow; $scriptBlock = 'Write-Host \"Setting up WSL port forwarding for Foxglove Bridge (port 8765)...\" -ForegroundColor Cyan; $wslIP = wsl hostname -I | ForEach-Object { $_.Trim() -split \"\\s+\" | Select-Object -First 1 }; Write-Host \"WSL IP Address: $wslIP\" -ForegroundColor Green; netsh interface portproxy delete v4tov4 listenport=8765 listenaddress=0.0.0.0 2>$null; Write-Host \"Cleaned up existing port proxy rules\" -ForegroundColor Yellow; netsh interface portproxy add v4tov4 listenport=8765 listenaddress=0.0.0.0 connectport=8765 connectaddress=$wslIP; Write-Host \"Added port proxy: 0.0.0.0:8765 -> $wslIP:8765\" -ForegroundColor Green; $firewallRule = Get-NetFirewallRule -DisplayName \"WSL Foxglove Bridge 8765\" -ErrorAction SilentlyContinue; if (-not $firewallRule) { New-NetFirewallRule -DisplayName \"WSL Foxglove Bridge 8765\" -Direction Inbound -LocalPort 8765 -Protocol TCP -Action Allow | Out-Null; Write-Host \"Added Windows Firewall rule for port 8765\" -ForegroundColor Green } else { Write-Host \"Windows Firewall rule already exists\" -ForegroundColor Yellow }; Write-Host \"\"; Write-Host \"Port forwarding configured successfully!\" -ForegroundColor Green; Write-Host \"\"; Write-Host \"Connect Foxglove Studio to:\" -ForegroundColor Cyan; Write-Host \"  ws://localhost:8765\" -ForegroundColor White; Write-Host \"  or\" -ForegroundColor Gray; Write-Host \"  ws://$wslIP:8765\" -ForegroundColor White; Write-Host \"\"; Write-Host \"Press any key to close...\"; $null = $Host.UI.RawUI.ReadKey(\"NoEcho,IncludeKeyDown\")'; $encoded = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($scriptBlock)); Start-Process powershell.exe -ArgumentList \"-ExecutionPolicy Bypass -NoProfile -EncodedCommand $encoded\" -Verb RunAs"
            ],
            "problemMatcher": [],
            "presentation": {
                "reveal": "always",
                "panel": "new",
                "focus": false,
                "echo": true,
                "showReuseMessage": true,
                "clear": false
            },
            "runOptions": {
                "runOn": "default"
            }
        },
        {
            "label": "Check WSL Port Forwarding",
            "type": "shell",
            "command": "powershell.exe",
            "args": [
                "-Command",
                "netsh interface portproxy show all; Write-Host ''; Test-NetConnection -ComputerName localhost -Port 8765 -InformationLevel Quiet"
            ],
            "windows": {
                "options": {
                    "shell": {
                        "executable": "powershell.exe",
                        "args": ["-NoProfile"]
                    }
                }
            },
            "problemMatcher": [],
            "presentation": {
                "reveal": "always",
                "panel": "new",
                "focus": false
            }
        },
        {
            "label": "Remove WSL Port Forwarding",
            "type": "shell",
            "command": "powershell.exe",
            "args": [
                "-Command",
                "netsh interface portproxy delete v4tov4 listenport=8765 listenaddress=0.0.0.0; Write-Host 'Port forwarding removed' -ForegroundColor Green"
            ],
            "windows": {
                "options": {
                    "shell": {
                        "executable": "powershell.exe",
                        "args": ["-NoProfile"]
                    }
                }
            },
            "problemMatcher": [],
            "presentation": {
                "reveal": "always",
                "panel": "new",
                "focus": false
            }
        }
    ]
}


The quickest fix: rename the bin file to code-tunnel

same issue. Can’t believe this isn’t fixed. I thought this was a VS code fork!

As of now this error still exists and you don’t need VSCode for a workaround. Everything is there:

  • look at the path the error (disguised as a warning) shows:
    <AppData-Local>\Programs\cursor\bin\code-tunnel.exe
    It might look a little different based on your system (this is windows11), but that’s the missing target.

  • So within the same root there is a source file you can use:
    <AppData-Local>\Programs\cursor\resources\app\bin\cursor-tunnel.exe
    It might also be slightly different based on your system

  • Just create the bin folder: <AppData-Local>\Programs\cursor\bin

  • Copy the file over there and rename it from cursor-tunnel.exe to code-tunnel.exe (THATS IMPORTANT!)

This problem should totally be solvable by the Cursor team, but I guess with 2.5K Github Issues at this point, that might not have a high priority - especially when there is a workaround. But it’s annoying to do this over and over again with every update deleting the bin folder. Especially when there are multiple Cursor updates in a week, or sometimes a day.

And also as mentioned before:
You have to kill the code-tunnel.exe from your Task manager manually afterwards

Thank you for raising this issue and for the detailed workaround. We have identified the cause for this issue and are fixing it in version 2.4 of Cursor, which should be released later this month.