Setting a port public/private in VS Code Browser
Setting a port public/private in a JetBrains IDE
3000-yourworkspace.ws-eu45.gitpod.io
You can also print the port URL using the gp url command (e.g. gp url 3000
).
And if you prefer listing all open ports URLs at once, use gp ports list command.
ports
section of your .gitpod.yml
.
All changes to port behaviors take effect immediately, not requiring a workspace restart.
Note: Some actions (e.g. setting a port public/private) can be taken via the IDE or editor.
.gitpod.yml
The property onOpen
configures port opening behaviors:
notify
(default) - Show a notification for newly detected ports.open-preview
- Open the port URL in a preview within the editor or IDE.open-browser
- Open the port URL in a browser tab.ignore
- Ignore default behavior (notify).name
and a description
(both optional). These properties will help you to add context about what the port is being used for.
Every exposed port's information and its corresponding actions can be found in the PORTS tab inside of VS Code Browser.
Every exposed port's information and its corresponding actions can be found in the EXPOSED PORTS tab inside of VS Code Desktop.
You can specify port names and descriptions via .gitpod.yml. Execute gp ports list in the terminal to output a table-formatted list of ports along with their status, URL, name and description. And update
visibility
configures who can access a port:
private
(default) - Only allow users with workspace access to access the port.public
- Allows everyone with the port URL to access the port..gitpod.yml
, changed via the Gitpod CLI, or manually changed within the IDE or editor.
PORTS
view or in the Gitpod CLI until they are opened.
.gitpod.yml
. Any undefined ports are sorted numerically in ascending order. Port ordering rules apply to all ports views, for example, when using gp ports list
or viewing ports in VS Code or JetBrains.
3000
to port localhost:3000
in the workspace.
ssh -L 3000:localhost:3000 <workspace-ssh-connection>
gp ssh
command to get workspace-ssh-connection
address. Also, please make sure you are running the above command in your local terminal (& not in the Gitpod workspace terminal).-N -R <port>:localhost:<port>
to the command and press enter, make sure to change the <port>
.
5000
, it would look like -N -R 5000:localhost:5000
.localhost:5000
.
Example Scenario:
python3 -m http.server 5000
.
curl -L http://localhost:9000
inside your Gitpod workspace, which will hit the port 5000 on your local machine’s HTTP server.fetch
request needs to have the credentials: "include"
option set. See the MDN doc’s credentials
description for more details.
Configure your server
In your server (the one on port 5001 in the above example), you have to configure the response to include the Access-Control-Allow-Credentials
header. Without it, your browser rejects the response and you see CORS errors in the browser console.
.gitpod.yml
or using the gp ports protocol
command.
.gitpod.yml
is the preferred approach to using the gp
CLI, as the .gitpod.yml
is declarative and ensures workspaces are created repeatably..gitpod.yml
ports
definition block in .gitpod.yml
to add the protocol
.
gp
gp ports protocol
command.
By default, ports are set as HTTP.
For example:
gp ports protocol 3000:https
will change port 3000
to use https
.gp ports protocol 3000:http
will change port 3000
to use http
.