>_dockerfix
← back to error wikihetzner

Hetzner Cloud server recreated from scratch loses its old IPv4 Primary IP

GET /servers/{id} → "public_net": {"ipv4": null, ...}
SSH and every service on the server's old IP time out after a rebuild

What's happening

When a Hetzner Cloud server is destroyed and recreated (as opposed to rebooted or put into rescue mode), the new server only automatically gets a fresh IPv6 address — it does not automatically reclaim the old server's IPv4 Primary IP. Primary IPs are independent, separately billed resources in Hetzner's model, and must be explicitly (re)assigned to a server. If your provisioning flow creates a new server without passing an explicit Primary IP assignment, the new VM can come up completely healthy on the inside while being totally unreachable on the IPv4 address everything else (DNS, monitoring, your own scripts) still expects — because that IP is now sitting unassigned (`assignee_id: null`) rather than attached to anything.

Fix

1. Check via the API whether the expected IP is actually attached: `GET /primary_ips` — look for your IP with `assignee_id: null`.
2. Power off the new server first — reattaching a Primary IP requires the target server to be off: `POST /servers/{id}/actions/poweroff`.
3. Reassign the IP: `POST /primary_ips/{ip_id}/actions/assign` with `{"assignee_id": <server_id>, "assignee_type": "server"}`.
4. Power back on: `POST /servers/{id}/actions/poweron`.
5. Going forward, pass the Primary IP explicitly in the server-create call instead of relying on 'sticky IP' assumptions, and periodically audit your account for orphaned Primary IPs (`GET /primary_ips` filtered to `assignee_id: null`) — they're billed whether attached to anything or not.
Got a different error? Paste it here for a free diagnosis.