Anysphere.remote-containers does not honor port forwarding configuration

Describe the Bug

In a recent cursor update the anysphere.remote-containers extension became mandatory. Unfortunately the port forwarding configuration contained in our .devcontainers/devcontainer.json is no longer honored. Here is an excerpt from our file:

{
  // ... redacted ...

  // The app has dependencies on the db and redis containers
  "dockerComposeFile": "docker-compose.yml",

  // ... redacted ...

  // Use 'forwardPorts' to make a list of ports inside the container available locally.
  // This can be used to network with other containers or the host.
  "forwardPorts": [
    5001, // Rails app http
    5002, // Rails app https
    8082, // esbuild LiveReload
    "db:5432", // Postgres
    "redis:6379" // Redis
  ],
  "portsAttributes": {
    "5001": {
      "label": "Application HTTP",
      "protocol": "http",
      "onAutoForward": "silent"
    },
    "5002": {
      "label": "Application HTTPS",
      "protocol": "https",
      "onAutoForward": "silent"
    },
    "8082": {
      "label": "esbuild LiveReload",
      "protocol": "http",
      "onAutoForward": "silent"
    },
    "db:5432": {
      "label": "postgresql",
      "onAutoForward": "silent"
    },
    "redis:6379": {
      "label": "redis",
      "onAutoForward": "silent"
    }
  },
  "otherPortsAttributes": {
    "onAutoForward": "ignore"
  },
}

Steps to Reproduce

Here is the docker-compose.yml that we are using:

version: "3"

volumes:
  db-volume:

services:
  app:
    image: mcr.microsoft.com/vscode/devcontainers/base:ubuntu-24.04
    restart: unless-stopped
    volumes:
      - ../..:/workspaces:cached

    # Overrides default command so things don't shut down after the process ends.
    command: sleep infinity
    environment:
      PGHOST: db
      PGUSER: postgres
      PGPASSWORD: postgres
      PGDATABASE: postgres
      DATABASE_URL: postgres://postgres:postgres@db:5432/postgres
      REDIS_URL: redis://redis:6379

    depends_on:
      - db
      - redis

  redis:
    image: "redis:alpine"
    restart: unless-stopped

  db:
    image: "postgres:14-alpine"
    restart: unless-stopped
    environment:
      POSTGRES_DB: postgres
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres

    volumes:
      - db-volume:/var/lib/postgresql/data

Expected Behavior

The devcontainer.json configuration is documented here: Dev Container metadata reference

“forwardPorts” // “portsAttributes” // “otherPortsAttributes” - should all behave as documented

Screenshots / Screen Recordings

Operating System

MacOS

Current Cursor Version (Menu → About Cursor → Copy)

Version: 1.2.4
VSCode Version: 1.99.3
Commit: a8e95743c5268be73767c46944a71f4465d05c90
Date: 2025-07-10T16:53:59.659Z (3 days ago)
Electron: 34.5.1
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Darwin arm64 24.5.0

Additional Information

prior to the extension update I could connect to the Postgres db from the host using:

postgres://postgres:postgres@localhost:5432/postgres

Does this stop you from using Cursor

Yes - Cursor is unusable

Hi @Si_Cruse, thank you for this bug report. We just published version 1.0.13 of the extension, which forwards the ports specified in the forwardPorts section. Could you try upgrading to the latest version?

We are working on implementing support for the portsAttributes and otherPortsAttributes.

Thank you for the swift response. it is very much appreciated. The patch has fixed the immediate blocker. Now that the extension is forwarding the ports I am able to connect to the app and the db from the development host.

Note that the “Ports” tab does not correctly reflect active processes (the first column).

  • The app in this example is actively running against ports 5001 & 5002.
  • The live reload service is actively running on port 8082.
  • Postgres & Redis containers are running and serving ports 5432 & 6379 (respectively)

Hi @Si_Cruse, could you try upgrading to the latest version of the extension? We fixed an issue in our implementation in 1.0.13 where ports defined in the “forwardPorts” section would always show up as “inactive” even when being forwarded.

Hi @ravirahman - The version in use is 1.0.14

Hi @Si_Cruse, we added support for portsAttributes and otherPortsAttributes, and added support for services running on ipv6, in version 1.0.16 of the Remote Containers extension. While we weren’t able to reproduce this issue exactly, it’s possible that these bugs were related. Could you try upgrading the extension to see if it helps?

Hi @ravirahman - progress, thanks!
for “portsAttributes” the “label” is working, the “onAutoForward” is not.
for “otherPortsAttributes” I haven’t tested deeply - but I do seem to be prompted whenever a new port is opened, even when “onAutoForward”: “silent”

Hi @Si_Cruse, thanks for flagging this issue with the “onAutoForward” behavior. In version 1.0.21 of the extension, we reimplemented this feature by copying the portsAttributes and otherPortsAttributes into the container’s settings.json, which is more reliable. Could you upgrade to the latest version of the Remote Containers extension?

You may need to rebuild the container after upgrading.

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.