LogoLogo
Foundry Documentation
Foundry Documentation
  • Welcome to Foundry
  • Quickstart guide
  • Compute & Storage
    • Compute overview
    • Instance types & specifications
    • Reserving compute
    • Spot bids
      • Spot auction mechanics
    • Startup scripts
    • Access & manage instances
      • Statuses
    • Compute quotas
    • Managing open ports
    • Persistent storage
      • File shares
      • Block storage
    • Hosted Kubernetes clusters
    • Ephemeral storage
  • Foundry API
    • API overview and quickstart
    • API reference
      • Projects
      • Instance types
      • SSH Keys
      • Volumes
      • Instances
      • Spot
        • Bids
        • Availability
      • API Keys
      • Profile
    • Specification
  • Access Management
    • Access Management Overview
    • SSH keys
  • Account and Billing
    • Billing overview
    • Foundry Referral Program
  • Security & trust
    • Foundry's approach to security
    • Reporting security concerns
Powered by GitBook
LogoLogo

© 2025 Foundry Technologies, Inc.

On this page
  • Manually opening and closing ports
  • Creating a systemd service to expose ports
  1. Compute & Storage

Managing open ports

A guide to exposing ports from your Foundry instances

Manually opening and closing ports

You can use the following to expose ports on your instances, replacing <port_number> with the port number you want to forward to your instance's public IP:

sudo foundrypf <port_number>

This will start a process that maintains the open port, and you may keep it running in the background with nohup.

You can close the port with the following command, replacing <port_number> with the port number you want to close:

sudo foundrypf -d <port_number>

Creating a systemd service to expose ports

If you want to ensure the port forwarding is kept running in the background persistently even after a system reboot or in the case that the process fails in the background due to network blips, you can create a systemd service for it.

Open a new service file using a text editor (in this case, nano):

sudo nano /etc/systemd/system/examplefoundry.service

Add the following content to the service file:

[Unit]  
Description=Foundry Port Forwarding Service  
After=network.target
Wants=network-online.target

[Service]  
Type=simple  
User=root  
ExecStart=/usr/local/bin/foundrypf <port_number>  
Restart=always  
RestartSec=3

[Install]  
WantedBy=multi-user.target

Again, replace <port_number> with the port you want to keep forwarded persistently.

sudo systemctl daemon-reload  
sudo systemctl enable examplefoundry  
sudo systemctl start examplefoundry

Now, the foundrypf script will run as a service, and the specified port will be forwarded persistently. Adjust the <port_number> and service file name if you wish to set up multiple such services for different ports.

Note that lower-number ports are currently not supported on foundrypf. We recommend running applications on higher-number ports.

PreviousCompute quotasNextPersistent storage

Last updated 7 months ago