Dev Containers Port forwarding problem

Describe the Bug

After switching to Cursor Dev Containers extension, I can’t access to my application from the intended port. On the port forwarding window, it shows that it forwards ports to a random port.

Steps to Reproduce

Open the project with dev containers and just run your app

Expected Behavior

My app runs on port 8000, i must be able to access it from localhost:8000, now i can only access from the random port curor gives. It works normally on vscode

Screenshots / Screen Recordings

Cursor (notice the random ports)


VScode (normal behavior)

Operating System

Windows 10/11

Current Cursor Version (Menu → About Cursor → Copy)

[Window Title]
Cursor

[Main Instruction]
Cursor

[Content]

Version: 1.2.1 (user setup)
VSCode Version: 1.99.3
Commit: 031e7e0ff1e2eda9c1a0f5df67d44053b059c5d0
Date: 2025-07-03T06:16:02.610Z (1 day ago)
Electron: 34.5.1
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Windows_NT x64 10.0.26100

Does this stop you from using Cursor

No - Cursor works, but with this issue

1 Like

I ran into this issue as well after updating Cursor yesterday. In my case there is no “random port” to connect to. As long as Cursor IDE is running, I’m locked out of the service I need to access. This is a showstopper for me and, as a consequence, I unfortunately have to stop using Cursor IDE until it’s fixed.

I also confirmed that VSCode does not have this issue. When I open my project in VSCode I can access the service via http://localhost:8081 without issue. The moment I fire up Cursor however, the page continuously tries to load in the browser but never finishes. I also get an error in the console whenever the initial HTTP request is made from my browser:

Error: connect ECONNREFUSED 127.0.0.1:port_number

Some details about my setup:

  • I am using the Dev Containers extension and it’s up to date. ms-vscode-remote is the id.
  • I have a docker compose stack running the full Camunda 8 suite of software. I simply added my devcontainer to the compose stack in .devcontainer/docker-compose.yaml. My devcontainer.json points to this compose file, and everything was working fine before I updated Cursor yesterday (7/3/2025).
  • I do happen to have a lot of ports mapped – 31 to be exact. I’m writing a Java application with Spring Boot and that can’t be helped unfortunately. There are no visible conflicts and this shouldn’t ultimately be a problem.
  • I’m running Mac OS X 15.5 on a MacBook Pro 16-inch, Nov 2024 with Apple M4 Pro with 48GB of RAM.

Firing up Cursor brings up the compose stack if it wasn’t already up previously. I cannot access the service on port 8081 as long as Cursor is running. Quitting cursor leaves the compose stack running in Docker. I can immediately access the service once Cursor is no longer running.

I tried the following but the problem persists:

  • Quit Cursor.
  • docker rm -f $(docker ps -aq) && docker volume prune -a -f && docker network rm $(docker network ls -q).
  • Start Cursor.

That amounts to a complete refresh of the entire docker compose stack, pulling fresh images and re-creating all docker networks fresh from config. This is definitely an issue with Cursor port forwarding in some form or fashion.

I hope this helps! I really love this product, please keep up the excellent work! :slight_smile:

Same problem here. In vscode works well with devcontainer.json configuration

same problem 3 days without a solution

I’m also facing the same issue.

I am having the same issue here as well. (along with several other issues with the new dev containers extension)

As we use dev containers for development I had to go back to VSCode for our development work.

I will have to keep an eye out until the several issues with the anysphere extension have been fixed until I can return to cursor :frowning: :frowning:

New DevContainers extension seems to have fixed this issue. It is possible to set target port as same as source port.

Hi @fenreer, @Nazareno_Pesado, and @tufantoksoz, @mrjarnould, and @Elwin – thank you for the bug report, and appreciate your patience with this issue.

Just to confirm, are you using the ms-vscode-remote.remote-containers extension or the anysphere.remote-containers extension?

We just pushed an update for the anysphere.remote-containers extension (version 1.0.13) that adds support for the forwardPorts section of the devcontainer.json. If you’re on an older version of the extension, could you try upgrading to the latest version?

If that still doesn’t work, could you share the logs for the “Remote - Dev Containers” output window so we can take a closer look? Thanks!

I can confirm that port forwarding works again for me.

1 small caveat with it:
image
The small green dot before some of my forwards are missing.
In VScode, the green dot indicates that a port forward is active and working, but for some reason in Cursor the dot stays white and unfilled in Cursor for some forwards (but works for others) with the exact same project, while the forward does indeed work and is active.

Hi @Elwin , we fixed this in version 1.0.14 of the extension. Ports defined with forwardPorts should now have the green dot when in use.