The Machine Runtime Environment

Environment variables make several kinds of information available within a Machine’s runtime environment. The values come from three sources:

Environment variables


FLY_APP_NAME

App name: Each app running on Fly.io has a unique app name. This identifies the app for the user, and can also identify its Machines on their IPv6 private network, using internal DNS. For example, syd.$FLY_APP_NAME.internal can refer to the app’s Machines running in the syd region. Read more about 6PN Naming in the Private Networking docs.

FLY_MACHINE_ID

Machine ID: The Machine’s unique ID on the Fly.io platform. This is the ID you use to target the Machine using flyctl and the Machines API. You can also see it in the log messages emitted by the Machine.

FLY_ALLOC_ID

Allocation ID: Same as the FLY_MACHINE_ID.

FLY_REGION

Region name: The three-letter name of the region the Machine is running in. Details of current regions are listed in the Regions page. As an example, “ams” is the region name for Amsterdam.

Not to be confused with the HTTP header Fly-Region, which is where the connection was accepted from.

FLY_PUBLIC_IP

IPV6 public IP: The full public outbound IPV6 address for this Machine. Read more in the Network Services section.

FLY_IMAGE_REF

Docker image reference: The name of the Docker image used to create the Machine. registry.fly.io/my-app-name:deployment-01H9RK9EYO9PGNBYAKGXSHV0PH is an example of the Docker Image Reference’s format.

Useful if your app needs to launch Machine instances of itself to scale background workers to zero and back, as in Rails Background Jobs with Fly Machines.

FLY_MACHINE_VERSION

Machine configuration version: A version identifier associated with a specific Machine configuration. When you update a Machine’s configuration (including when you update its Docker image), it gets a new FLY_MACHINE_VERSION. Changing the Machine’s metadata using the metadata endpoint of the Machines API doesn’t trigger a new version. You can also find this value under the name Instance ID in the output of fly machine status.

FLY_PRIVATE_IP

Private IPv6 address: The IPv6 address of the Machine on its 6PN private network.

FLY_PROCESS_GROUP

Process group: The Fly Launch process group associated with the Machine, if any.

FLY_VM_MEMORY_MB

Machine memory: The memory allocated to the Machine, in MB. It’s the same value you’ll find under https://fly.io/dashboard/personal/machines and VM Memory in the output of fly machine status. Learn more about Machine sizing.

PRIMARY_REGION

Primary region: This is set in your fly.toml or with the --region flag during deploys. Learn more about configuring the primary region.