You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow specifying local port when setting up port forward #761
I'd just like to leave a small wish here that VS Code doesn't grow a strong dependency on reverse/remote port forwarding. My experience with getting VS Code accepted with IT in a big enterprise was that AllowTcpPorwarding=local was an acceptable sshd setting that they were willing to roll out, but nothing more.
Hey Ethan Spitz (@ethanspitz),
I was just wishing for the same feature too, and found this feature request.
However after some digging, I figured out it already exists! 😃
First forward a port, then right click on it and select Change Local Port:
Jeremy Glenn Lopez (@jglopez), fantastic find. Now that it is obvious it is easily accomplished and the ability already exists in VSCode, we should improve the "Forward a Port" in the Command Palette to allow accepting a different local port.
This issue has been marked for ssh specifically, however it applies to Dev-Containers just the same.
Currently from Command Palette the "Forward a Port" currently only accepts a single number:
For example: 8080
This should be changed to allow both a single number or two colon delimited numbers:
For example: 8080 80:8080
The 8080 would continue to create port forwarding for 8080 -> localhost:8080 as it does today, however the second "80:8080" version would create port forwarding for 8080 -> localhost:80.
Tolga Balci (@tolgabalci) Yeah, I was wishing for the exact same functionality/syntax too. I was slightly disappointed the current implementation only allows changing the local port after the fact, and not exactly "when setting up port forward"... if you're taking this feature request's title literally word for word.
However, I'm very happy regardless the functionally exists at all. (And write the docs for it 😄)
After I learned it exists, this changed from an "absolutely necessary" to a "nice to have".
At the end of the day, I personally am not too inconvenienced by a few more mouse clicks.
I'd leave it to the VS Code product managers to decide on closing this and reopening a new Issue (as it technically already exists), or leaving it open for our specific use case.
every time i restart dev server on remote machine, my local forward port changed.
this is very annoying...
is there any way for me to specific the local forward port and make it stable?
Activity
egamma commentedon Jun 21, 2019
Which remote extension are you using?
ethanspitz commentedon Jun 21, 2019
davidwin commentedon Jun 23, 2019
I'd just like to leave a small wish here that VS Code doesn't grow a strong dependency on reverse/remote port forwarding. My experience with getting VS Code accepted with IT in a big enterprise was that
AllowTcpPorwarding=localwas an acceptablesshdsetting that they were willing to roll out, but nothing more.[-]Make port forwarding great again.[/-][+]Allow specifying local port when setting up port forward[/+]jglopez commentedon Jun 17, 2020
Hey Ethan Spitz (@ethanspitz),
I was just wishing for the same feature too, and found this feature request.
However after some digging, I figured out it already exists! 😃
First forward a port, then right click on it and select Change Local Port:

And I found its original commit at: microsoft/vscode@b72188e
Unfortunately, I don't believe it's documented at either:
Although, now I'm considering just writing it up and adding at:
https://github.com/microsoft/vscode-docs/blob/master/docs/remote/ssh.md#forwarding-a-port--creating-ssh-tunnel
ethanspitz commentedon Jun 17, 2020
jglopez commentedon Jun 17, 2020
FYI, I just finished writing the docs up! 😄
See PR: microsoft/vscode-docs#3788
tolgabalci commentedon Jul 19, 2020
Jeremy Glenn Lopez (@jglopez), fantastic find. Now that it is obvious it is easily accomplished and the ability already exists in VSCode, we should improve the "Forward a Port" in the Command Palette to allow accepting a different local port.
This issue has been marked for ssh specifically, however it applies to Dev-Containers just the same.
Currently from Command Palette the "Forward a Port" currently only accepts a single number:
For example:
8080This should be changed to allow both a single number or two colon delimited numbers:
For example:
808080:8080The 8080 would continue to create port forwarding for 8080 -> localhost:8080 as it does today, however the second "80:8080" version would create port forwarding for 8080 -> localhost:80.
jglopez commentedon Jul 19, 2020
Tolga Balci (@tolgabalci) Yeah, I was wishing for the exact same functionality/syntax too. I was slightly disappointed the current implementation only allows changing the local port after the fact, and not exactly "when setting up port forward"... if you're taking this feature request's title literally word for word.
However, I'm very happy regardless the functionally exists at all. (And write the docs for it 😄)
After I learned it exists, this changed from an "absolutely necessary" to a "nice to have".
At the end of the day, I personally am not too inconvenienced by a few more mouse clicks.
I'd leave it to the VS Code product managers to decide on closing this and reopening a new Issue (as it technically already exists), or leaving it open for our specific use case.
dennisleung commentedon Jan 18, 2021
every time i restart dev server on remote machine, my local forward port changed.
this is very annoying...
is there any way for me to specific the local forward port and make it stable?
tanhakabir commentedon Oct 29, 2021
dennisleung (@dennisleung) hm sorry about that! If you're still facing that issue, it would be great if you could file an issue for it.
I'm going to close this issue since it seems like the request is already supported now. Let me know if any of you think otherwise!