Back to Vagrant

Port

website/content/docs/cli/port.mdx

2.4.91.4 KB
Original Source

⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

[!IMPORTANT]
Documentation Update: Product documentation previously located in /website has moved to the hashicorp/web-unified-docs repository, where all product documentation is now centralized. Please make contributions directly to web-unified-docs, since changes to /website in this repository will not appear on developer.hashicorp.com. ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

Port

Command: vagrant port [name|id]

The port command displays the full list of guest ports mapped to the host machine ports:

shell-session
$ vagrant port
    22 (guest) => 2222 (host)
    80 (guest) => 8080 (host)

In a multi-machine Vagrantfile, the name of the machine must be specified:

shell-session
$ vagrant port my-machine

Options

  • --guest PORT - This displays just the host port that corresponds to the given guest port. If the guest is not forwarding that port, an error is returned. This is useful for quick scripting, for example:

    shell-session
    $ ssh -p $(vagrant port --guest 22)
    
  • --machine-readable - This tells Vagrant to display machine-readable output instead of the human-friendly output. More information is available in the machine-readable output documentation.