-
Using GitHub Codespaces with JetBrains IDEs is currently in public beta and is subject to change. -
To work on a codespace in a JetBrains IDE you must use release 2023.3.* or 2024.1.* of the JetBrains Gateway.
About forwarded ports
Forwarding a port
-
Open the terminal in your codespace. -
Click the PORTS tab. -
Under the list of ports, click Add port . -
Type the port number or address, then press Enter.
Using HTTPS forwarding
-
Open the terminal in your codespace. -
Click the PORTS tab. -
Right-click the port you want to update, then hover over Change Port Protocol . -
Select the protocol needed for this port. The protocol that you select will be remembered for this port for the lifetime of the codespace.
Sharing a port
-
Open the terminal in your codespace. -
Click the PORTS tab. -
Right-click the port that you want to share, click the Port Visibility , then click Private to Organization or Public . -
To the right of the local address for the port, click the copy icon. -
Send the copied URL to the person you want to share the port with.
Using command-line tools and REST clients to access ports
Finding the address to connect to
-
Open the terminal in your codespace. -
Click the PORTS tab. This lists all of the ports you have forwarded. -
Right-click the port you want to connect to and click Copy Local Address . -
Paste the copied address somewhere for later use.
Finding the GITHUB_TOKEN
-
In the terminal in your codespace, enter echo $GITHUB_TOKEN . The token is a string beginning ghu_ . -
Copy the token. Important : Don't share this access token with anyone.
Using curl to access a forwarded port
curl ADDRESS -H "X-Github-Token: TOKEN"
Using Postman to access a forwarded port
-
Open Postman. -
Create a new GET request. -
Paste the address you copied previously as the request URL. -
In the Headers tab, create a new entry where the key is "X-Github-Token" and the value is the GITHUB_TOKEN you copied previously. -
Click Send .
Automatically forwarding a port
-
In your codespace, open the dev container configuration file you want to update. Typically this file is .devcontainer/devcontainer.json . -
Add the forwardPorts property. "forwardPorts" : [ NUMBER ] , Replace NUMBER with the port number you want to forward. This can be a comma-separated list of port numbers. -
Save the file.
Labeling a port
-
Open the terminal in your codespace. -
Click the PORTS tab. -
Right-click the port you want to label, then click Set Port Label . -
Type a label for your port, then press Enter.
Automatically labeling a forwarded port
-
Open the terminal in your codespace. -
Click the PORTS tab. -
Right-click the port whose label attribute you want to add to the codespace configuration, then click Set Label and Update devcontainer.json . -
Type a label for your port, then press Enter. -
If your repository has more than one dev container configuration file, you will be prompted to choose which file you want to update. The dev container configuration file is updated to include the new label in the portsAttributes property. For example: // Use 'forwardPorts' to make a list of ports inside the container available locally. "forwardPorts" : [ three thousand three hundred and thirty-three , four thousand four hundred and forty-four ] , "portsAttributes" : { "3333" : { "label" : "app-standard-preview" } , "4444" : { "label" : "app-pro-preview" } }
Forwarding a port
-
Open the terminal in your codespace. -
Click the PORTS tab. -
Under the list of ports, click Add port . -
Type the port number or address, then press Enter.
Sharing a port
-
Open the terminal in your codespace. -
Click the PORTS tab. -
Right-click the port that you want to share, click Port Visibility , then click Private to Organization or Public . -
To the right of the local address for the port, click the copy icon. -
Send the copied URL to the person you want to share the port with.
Using command-line tools and REST clients to access ports
Finding the address to connect to
-
Open the terminal in your codespace. -
Click the PORTS tab. This lists all of the ports you have forwarded. -
Right-click the port you want to connect to and click Copy Local Address . -
Paste the copied address somewhere for later use.
Finding the GITHUB_TOKEN
-
In the terminal in your codespace, enter echo $GITHUB_TOKEN . The token is a string beginning ghu_ . -
Copy the token. Important : Don't share this access token with anyone.
Using curl to access a forwarded port
curl ADDRESS -H "X-Github-Token: TOKEN"
Using Postman to access a forwarded port
-
Open Postman. -
Create a new GET request. -
Paste the address you copied previously as the request URL. -
In the Headers tab, create a new entry where the key is "X-Github-Token" and the value is the GITHUB_TOKEN you copied previously. -
Click Send .
Automatically forwarding a port
-
In your codespace, open the dev container configuration file you want to update. Typically this file is .devcontainer/devcontainer.json . -
Add the forwardPorts property. "forwardPorts" : [ NUMBER ] , Replace NUMBER with the port number you want to forward. This can be a comma-separated list of port numbers. -
Save the file.
Labeling a port
-
Open the terminal in your codespace. -
Click the PORTS tab. -
Right-click the port you want to label, then click Set Port Label . -
Type a label for your port, then press Enter.
Automatically labeling a forwarded port
-
Open the terminal in your codespace. -
Click the PORTS tab. -
Right-click the port whose label attribute you want to add to the codespace configuration, then click Set Label and Update devcontainer.json . -
Type a label for your port, then press Enter. -
If your repository has more than one dev container configuration file, you will be prompted to choose which file you want to update. The dev container configuration file is updated to include the new label in the portsAttributes property. For example: // Use 'forwardPorts' to make a list of ports inside the container available locally. "forwardPorts" : [ three thousand three hundred and thirty-three , four thousand four hundred and forty-four ] , "portsAttributes" : { "3333" : { "label" : "app-standard-preview" } , "4444" : { "label" : "app-pro-preview" } }
gh codespace ports forward CODESPACE-PORT:LOCAL-PORT
Sharing a port
private - Visible only to you. This is the default setting when you forward a port. org - Visible to members of the organization that owns the repository. public - Visible to anyone who knows the URL and port number.
gh codespace ports visibility CODESPACE-PORT:SETTINGS
gh codespace ports visibility 80:private 3000:public 3306:org
Using command-line tools and REST clients to access ports
Finding the address to connect to
Finding the GITHUB_TOKEN
-
Start an SSH session for your codespace. gh codespace ssh -
If you have more than one codespace, select the appropriate codespace from the list that's displayed. -
Display the GITHUB_TOKEN . echo $GITHUB_TOKEN The token is a string beginning ghu_ . -
Copy the token. Important : Don't share this access token with anyone. -
Exit the SSH session. exit
Using curl to access a forwarded port
curl ADDRESS -H "X-Github-Token: TOKEN"
Using Postman to access a forwarded port
-
Open Postman. -
Create a new GET request. -
Paste the address you copied previously as the request URL. -
In the Headers tab, create a new entry where the key is "X-Github-Token" and the value is the GITHUB_TOKEN you copied previously. -
Click Send .
Automatically forwarding a port
-
In your codespace, open the dev container configuration file you want to update. Typically this file is .devcontainer/devcontainer.json . -
Add the forwardPorts property. "forwardPorts" : [ NUMBER ] , Replace NUMBER with the port number you want to forward. This can be a comma-separated list of port numbers. -
Save the file.
Labeling a port
-
Open the terminal in your codespace. -
Click the PORTS tab. -
Right-click the port you want to label, then click Set Port Label . -
Type a label for your port, then press Enter.
Automatically labeling a forwarded port
-
Open the terminal in your codespace. -
Click the PORTS tab. -
Right-click the port whose label attribute you want to add to the codespace configuration, then click Set Label and Update devcontainer.json . -
Type a label for your port, then press Enter. -
If your repository has more than one dev container configuration file, you will be prompted to choose which file you want to update. The dev container configuration file is updated to include the new label in the portsAttributes property. For example: // Use 'forwardPorts' to make a list of ports inside the container available locally. "forwardPorts" : [ three thousand three hundred and thirty-three , four thousand four hundred and forty-four ] , "portsAttributes" : { "3333" : { "label" : "app-standard-preview" } , "4444" : { "label" : "app-pro-preview" } }
Seeing port labels on the command line
Forwarding a port