What's not here, and why. Server provisioning belongs in Terraform (the Hetzner provider is excellent).
hcloud image create from a running server. Use server create-image instead. Managed Kubernetes (HCloud K3s) is not a first-party managed service. Use Hetzner's K3s tutorials or Terraform modules. Object Storage uses S3-compatible API. Use AWS CLI with Hetzner's endpoint.
cross-cutting: know these before anything else
context (multi-account)
hcloud context create prod
hcloud context use prod
hcloud context list
hcloud context active
# or: HCLOUD_TOKEN=xxx hcloud server list
--output + selectors
hcloud server list -o columns=id,name,status,ipv4,type
hcloud server list -o json | jq '.[].name'
hcloud server list -l env=prod
# -l / --selector filters by label key=value
# label selectors are the primary targeting mechanism
locations + server types
hcloud location list
hcloud server-type list -o columns=id,name,cores,memory,disk,storage_type,price_monthly
hcloud image list --type system -o columns=id,name,description | grep ubuntu
# Hetzner locations: nbg1 fsn1 hel1 ash (US) hil (US) sin (SG)
| Service | Phase | Key commands | Use case |
|---|---|---|---|
| hcloud context | auth |
hcloud context create prod
hcloud context create staging
hcloud context use prod
hcloud context list
hcloud context delete staging
# tokens stored in ~/.config/hcloud/cli.toml
# CI: HCLOUD_TOKEN=xxx hcloud server list
|
hcloud contexts are project-level API tokens: each Hetzner project has its own token. Named contexts let you switch between projects cleanly. In CI, use the HCLOUD_TOKEN env var scoped to the command rather than storing it in the config file. Tokens are generated per-project in the Hetzner Cloud Console under Security → API Tokens. |
| server list / inspect | servers |
hcloud server list -o columns=id,name,status,ipv4,type,datacenter,labels
hcloud server describe <name-or-id>
hcloud server list -l env=prod -o columns=id,name,ipv4,status
hcloud server list -o json | jq '.[] | select(.status != "running") | {id,name,status}'
hcloud server metrics --type cpu --start $(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%SZ) --end $(date -u +%Y-%m-%dT%H:%M:%SZ) <id>
|
Label selectors (-l env=prod) are the primary fleet targeting mechanism in hcloud: more reliable than name-matching. describe gives full server details including attached volumes, networks, and firewall. metrics returns CPU, disk I/O, and network stats for a time range: useful for a quick perf snapshot without opening the console. |
| server power ops | servers |
hcloud server poweroff <name>
hcloud server poweron <name>
hcloud server reboot <name>
hcloud server reset <name>
hcloud server shutdown <name>
# shutdown: graceful ACPI; poweroff: hard cut; reset: hard reset
|
shutdown sends an ACPI shutdown signal: the OS shuts down cleanly. poweroff cuts power immediately. Use only when the OS is unresponsive. reset is equivalent to pressing the reset button. For scripted operations, prefer shutdown and poll status until the server is off before proceeding. |
| server SSH + console | servers |
hcloud server ssh <name>
hcloud server ssh <name> -u deploy -p 2222
hcloud server ssh <name> -- df -h
hcloud server enable-rescue <name> --type linux64 --ssh-keys mykey
hcloud server console <name>
|
hcloud server ssh resolves the server's IP and connects using your SSH key: cleaner than looking up the IP manually. enable-rescue boots into a live rescue system on next start: the correct approach when a server won't boot and you need to repair the filesystem or recover data. console opens a VNC console in the browser. |
| server images + rebuild | servers |
hcloud image list --type snapshot -o columns=id,name,description,created,disk_size
hcloud server create-image --type snapshot --description myapp-$(date +%Y%m%d) <name>
hcloud server rebuild <name> --image ubuntu-24.04
hcloud image delete <id>
hcloud image list --type snapshot -o json | jq '.[] | select(.created < "2025-01-01") | .id'
|
create-image snapshots a running server: a snapshot of a live server may have inconsistent filesystem state if writes are in flight; prefer shutting down first for critical data. rebuild reinstalls the OS from an image: wipes all data. The jq date filter identifies old snapshots for cleanup; snapshots are billed at €0.0115/GB/month. |
| server resize | servers |
hcloud server change-type <name> --server-type cx31 --upgrade-disk=false
hcloud server-type list -o columns=name,cores,memory,disk,price_monthly | grep cx
# server must be powered off before change-type
# --upgrade-disk=false allows downgrading type later
# disk upgrades are permanent: cannot be reverted
|
--upgrade-disk=false is critical if you ever want to resize down later: disk upgrades are permanent. Hetzner server types are CX (shared CPU), CPX (AMD shared CPU), CCX (dedicated CPU), CAX (Arm64). Shared CPU types are excellent for bursty workloads; dedicated for consistent performance. |
| private networks | networks |
hcloud network list -o columns=id,name,ip_range,servers,subnets
hcloud network describe <name>
hcloud network add-subnet <name> --network-zone eu-central --type cloud --ip-range 10.0.1.0/24
hcloud server attach-to-network <server> --network <network> --ip 10.0.1.10
hcloud server detach-from-network <server> --network <network>
|
Private networks are free in Hetzner. Always attach servers to a private network rather than communicating over public IPs. --ip assigns a static private IP: omit for auto-assignment. Network zones (eu-central, us-east, us-west, ap-southeast) determine which datacenters the network spans. A server can be in multiple networks simultaneously. |
| floating IPs | networks |
hcloud floating-ip list -o columns=id,name,ip,type,location,server
hcloud floating-ip assign <ip-id> <server-name>
hcloud floating-ip unassign <ip-id>
hcloud floating-ip create --type ipv4 --home-location nbg1 --name prod-ingress
# unassigned floating IPs are still billed: €0.0019/hour
# must configure the IP inside the OS, not automatic
|
Floating IPs enable zero-downtime failover: reassign the IP to a standby server in seconds. They must be configured inside the OS (add to the network interface): the Hetzner docs provide the exact ip addr add commands per distribution. Unassigned floating IPs still cost money: release them when not in use. |
| volumes (block storage) | storage |
hcloud volume list -o columns=id,name,size,location,server,status
hcloud volume attach <volume> --server <server>
hcloud volume detach <volume>
hcloud volume resize <volume> --size 100
hcloud volume delete <volume>
# after resize, grow the filesystem inside the server:
# resize2fs /dev/disk/by-id/scsi-0HC_Volume_<id>
|
Volumes attach to servers in the same location only. You can't attach a Nuremberg volume to a Helsinki server. After CLI resize, the block device grows immediately but the filesystem doesn't. Run resize2fs (ext4) or xfs_growfs (xfs) inside the server. Volumes without an attached server are still billed at €0.0239/GB/month. |
| Object Storage (S3-compatible) | storage |
# Hetzner Object Storage uses S3-compatible API
# endpoint: https://<location>.your-objectstorage.com
aws s3 ls --endpoint-url https://fsn1.your-objectstorage.com
aws s3 sync ./dist s3://mybucket --endpoint-url https://fsn1.your-objectstorage.com
aws s3 presign s3://mybucket/file.tar.gz --endpoint-url https://fsn1.your-objectstorage.com --expires-in 3600
# credentials: access key + secret from console (not API token)
|
Object Storage is not managed via hcloud CLI. Use the AWS CLI with Hetzner's S3-compatible endpoint. Credentials are separate from the API token: generate access keys in the console under Object Storage. Available in Falkenstein (fsn1), Nuremberg (nbg1), and Helsinki (hel1). €0.0059/GB/month: the cheapest in this comparison. |
| load balancer list / inspect | load balancers |
hcloud load-balancer list -o columns=id,name,ipv4,type,location,services,targets
hcloud load-balancer describe <name>
hcloud load-balancer metrics --type open_connections --start $(date -u -d '1h ago' +%Y-%m-%dT%H:%M:%SZ) --end $(date -u +%Y-%m-%dT%H:%M:%SZ) <name>
|
describe shows all targets and their health status: the first stop when traffic stops routing correctly. metrics returns open connections, requests/sec, and bandwidth over a time range: useful for diagnosing traffic spikes. Hetzner LBs support HTTP, HTTPS, and TCP: configure SSL termination with a managed certificate or your own. |
| load balancer targets | load balancers |
hcloud load-balancer add-target <lb> --server <server>
hcloud load-balancer add-target <lb> --label-selector env=prod
hcloud load-balancer remove-target <lb> --server <server>
hcloud load-balancer enable-public-interface <lb>
hcloud load-balancer disable-public-interface <lb>
|
Label selector targets (--label-selector env=prod) automatically include any server matching the selector: new servers with that label are added dynamically without modifying the LB. This is the correct pattern for autoscaling groups. disable-public-interface makes the LB internal-only: serves only from the private network. |
| load balancer services | load balancers |
hcloud load-balancer add-service <lb> --protocol https --listen-port 443 --destination-port 8080 --http-certificates <cert-id>
hcloud load-balancer update-health-check <lb> --protocol http --port 8080 --path /health --interval 10 --timeout 5 --retries 3
hcloud load-balancer remove-service <lb> --listen-port 80
hcloud certificate list -o columns=id,name,type,domain_names,not_valid_after
|
Health check path and interval are the first things to audit when the LB marks targets unhealthy. The certificate list shows expiry dates: Hetzner managed certificates (type=managed) auto-renew; uploaded certificates don't. Update the health check to use a dedicated endpoint that checks dependencies, not just HTTP 200. |
| firewall list / rules | firewalls |
hcloud firewall list -o columns=id,name,rules_count,applied_to
hcloud firewall describe <name>
hcloud firewall add-rule <name> --direction in --protocol tcp --port 443 --source-ips 0.0.0.0/0 --source-ips ::/0
hcloud firewall add-rule <name> --direction in --protocol tcp --port 22 --source-ips 10.0.0.0/8
hcloud firewall delete-rule <name> --direction in --protocol tcp --port 80 --source-ips 0.0.0.0/0
|
Hetzner firewalls default to deny all inbound when first applied. Add all required rules before applying to a server. Both IPv4 and IPv6 source ranges must be specified separately for rules that should apply to all traffic. Describe shows applied_to targets: servers or label selectors that the firewall is protecting. |
| firewall apply / remove | firewalls |
hcloud firewall apply-to-resource <name> --server <server>
hcloud firewall apply-to-resource <name> --label-selector env=prod
hcloud firewall remove-from-resource <name> --server <server>
hcloud server describe <name> -o json | jq '.firewalls'
|
Label selector application is the correct pattern for fleet management: any server with the matching label gets the firewall automatically. server describe | jq .firewalls confirms which firewalls are applied to a specific server and their status: applied means rules are active, pending means changes are in progress. |
| SSH keys | firewalls |
hcloud ssh-key list -o columns=id,name,fingerprint
hcloud ssh-key create --name mykey --public-key-from-file ~/.ssh/id_ed25519.pub
hcloud ssh-key describe <name>
hcloud ssh-key delete <name>
# keys are referenced by name at server creation time
# adding a key after creation requires manual authorized_keys edit
|
SSH keys registered in hcloud are injected at server creation only: adding a new team member's key later requires manual authorized_keys editing or a rebuild. Keep team SSH keys registered in hcloud and reference all of them at creation time. Use Ed25519 keys; RSA 2048 works but Ed25519 is faster and generates shorter authorized_keys entries. |
No entries match this filter.