microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.63k stars 282 forks source link

Port forwarding should support IPv6 #7029

Open doggy8088 opened 2 years ago

doggy8088 commented 2 years ago

Steps to Reproduce:

  1. clone the project & open with vscode

    git clone https://github.com/doggy8088/devcontainer-dotnet-mssql-ipv6-issue.git
    code devcontainer-dotnet-mssql-ipv6-issue
  2. Reopen in Container

  3. Here is the PORTS info.

    image

  4. Connect to localhost locally using sqlcmd

    sqlcmd -S localhost -U sa -P P@ssw0rd -Q "SELECT 1;"

    It will result:

    Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Named Pipes Provider: Could not open a connection to SQL Server [2]. .
    Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
    Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
  5. Connect to 127.0.0.1 locally using sqlcmd

    sqlcmd -S 127.0.0.1 -U sa -P P@ssw0rd -Q "SELECT 1;"

    It will run successfully.

    -----------
            1
    
    (1 rows affected)

I really expected I can connect to the db container using localhost. It because the PORTS shows that.

During few hours research, I realized that Windows use IPv6 by default. When VSCode use IPv4 to do the port forwarding, connect to localhost will route to ::1 and it will failed.

Two suggestions:

  1. Change the Local Address to show 127.0.01:1433 on the PORTS window.

  2. Port forwarding support IPv6.

Rar9 commented 1 year ago

I can connect via ssh remote to ubuntu 22.04 server.

Then I start in vsc terminal via npm run dev the node app.

This will open ssh tunnel(s) with the particular port(s) and the button to open browser appears.

But after this the browser will not receive any further data if the connection is done via IPv6.

So either Vsc or Windows11 issue.

Ubuntu server can curl the localhost and will display the browser data.

Lord-Leonard commented 1 year ago

@Rar9 did you get it to work?

Rar9 commented 1 year ago

No for now I've disabled IPv6 localhost on server

4llan commented 5 months ago

I had some dev containers that port forwarding was not working as expected when listening to localhost. After downgrading the remote and dev container extensions, I just noticed that the application was listening to the IPv6 loopback address (::1).

Steps to reproduce the issue:

You see a message of vscode telling that the port is auto forwarded, but there's no response in the forwarded address. Also, there's a message in the "Shared" output about the forwarding:

... [info] [SharedProcessTunnelService] Created tunnel 9: localhost:7777 (local) to 0:0:0:0:0:0:0:1:7777 (remote).

Starting a server to the IPv4 loopback works as expected (python -m http.server --bind 127.0.0.1 7778).