- Introduction
- Getting started
- Configuration
- Dev Container
- Automations
- Editors
- VS Code
- Cursor
- JetBrains
- Zed
- Gitpod Desktop
- Self-Hosted Runner
- AWS
- Azure
Coming soon
- GCP
Coming soon
- Linux
Coming soon
- Source Control
- GitHub
- GitLab
Coming soon
- Bitbucket
Coming soon
- Integrations
- Port sharing
- Personal access tokens
- Administration
- Organizations
- Projects
- Billing
- Reference
- CLI
Port sharing
Port sharing allows you to expose HTTP ports from your running Gitpod environment to the internet, enabling easy sharing and collaboration. This feature is available for cloud-hosted Gitpod environments not Gitpod Desktop environments.
How it works
When you share a port, Gitpod creates a public URL with automatic TLS termination. This allows secure access to your application or service running inside the Gitpod environment. Only HTTP traffic is supported for shared ports.
Sharing ports
There are two ways to share ports from your Gitpod environment:
Using the UI
In the Gitpod UI, you’ll see a section labeled “Public Ports” that allows you to manage port sharing for your environment.
To share a new port:
- Click the “Open Port” button in the “Public Ports” section.
- A dialog will appear titled “Open a public port”.
- Enter a name for the port (optional) and the port number you wish to share.
- Click “Open Port” to confirm.
For ports that are already open:
They will be listed in the “Public Ports” section. Each open port will show its name (if given) and port number. A green indicator next to the port signifies it’s currently active and accessible.
Security notice: When you open a port, it will be available on the open internet. Be careful when sharing the URL.
This interface provides an easy way to manage which ports are exposed from your Gitpod environment, allowing you to quickly share access to services or applications you’re running.
Using the CLI
Gitpod provides a set of CLI commands to manage port sharing. These commands allow you to list, open, and close ports directly from your terminal.
Listing ports
To view all currently open ports:
gitpod environment port list
This command will display a list of all ports that are currently open and available for sharing.
Opening a Port
To open and share a new port:
gitpod environment port open 3000 --name my-app
Closing a Port
To close a previously opened port:
gitpod environment port close
For example, to close port 3000:
gitpod environment port close 3000
Examples
Open a port for a web server:
gitpod environment port open 8080 --name webserver
Open a port for an API server:
gitpod environment port open 4000 --name api
List all open ports:
gitpod environment port list
Close a port that’s no longer needed:
gitpod environment port close 4000
These CLI commands provide a quick and efficient way to manage port sharing directly from your terminal, especially useful for scripting or when you prefer command-line interactions.
Use Cases
Port sharing enables various scenarios that enhance development workflows and collaboration:
Demonstrating work-in-progress: Quickly share your application with teammates or clients without deploying to a staging environment.
API testing: Expose your local API server to test integrations with external services or mobile apps.
Collaborative debugging: Share a running application with a colleague to troubleshoot issues together in real-time.
Design reviews: Make your local development server accessible so designers can review and provide feedback on UI changes.
Webhooks development: Test webhook integrations by exposing your local server to receive real-time events from external services.
Security considerations
While port sharing is convenient, it’s important to be mindful of security:
- Only share ports when necessary and unshare them when you’re done.
- Be cautious about sharing ports running sensitive services or containing confidential data.
- Remember that shared URLs are public and potentially accessible by anyone with the link.
Limitations and requirements
- Port sharing is only available for HTTP traffic.
- It’s not supported on Gitpod Desktop environments.
- Shared ports are subject to Gitpod’s fair use policies and may have bandwidth limitations.
- Important: Services must listen on
0.0.0.0
and not justlocalhost
for port sharing to work. This allows the service to accept connections from outside the local environment.
For example, if you’re running a Node.js server, make sure to bind it to 0.0.0.0
instead of localhost
:
const app = express();
app.listen(3000, '0.0.0.0', () => {
console.log('Server is running on port 3000');
});
If your service is only bound to localhost
or 127.0.0.1
, it won’t be accessible via port sharing even if the port is opened. Always ensure your services are configured to listen on 0.0.0.0
when you intend to use Gitpod’s port sharing feature.
Port sharing in Gitpod Flex streamlines the process of making your work accessible to others, fostering collaboration and simplifying development workflows. Whether you’re showcasing a project, testing integrations, or working with teammates, this feature provides a quick and secure way to expose your applications to the internet.