Skip to content

fix: refresh server IP after web server restore#4542

Open
NoelisTired wants to merge 1 commit into
Dokploy:canaryfrom
NoelisTired:fix/refresh-server-ip-on-restore
Open

fix: refresh server IP after web server restore#4542
NoelisTired wants to merge 1 commit into
Dokploy:canaryfrom
NoelisTired:fix/refresh-server-ip-on-restore

Conversation

@NoelisTired
Copy link
Copy Markdown

What

When restoring a Dokploy web server backup, the PostgreSQL database is restored as-is. That database row (webServerSettings) contains the serverIp of the machine the backup was originally taken on, so after restoring a backup onto a different host the dashboard keeps displaying the old "Server IP" indefinitely.

This PR re-detects the current host's public IP once the database restore finishes and persists it, so the restored instance reflects the machine it is actually running on.

How

In restoreWebServerBackup (packages/server/src/utils/restore/web-server.ts), right after the database pg_restore completes:

  • Call getPublicIpWithFallback() (the same helper used during initial setup in lib/auth.ts).
  • If an IP is detected, persist it via updateWebServerSettings({ serverIp }).
  • If detection fails, leave the existing value untouched and emit a warning so the user knows to set it manually in Web Server settings.

This mirrors exactly how serverIp is populated when the first admin is created, so there's no new detection logic — just reuse of the existing path at the right moment.

Why this scope

Kept intentionally narrow to the reported "Server IP stays stale after restore" bug. Other instance-specific values that are also restored from the backup (metrics callback URLs, SSH keys, registry URLs, bind-mount/cert paths, ACME data) can be stale after restoring onto a new host too, but those are separate concerns and are out of scope here.

Testing

  • Added apps/dokploy/__test__/restore/web-server.test.ts (vitest) covering:
    • IP is re-detected and persisted after a successful restore.
    • The stored IP is not overwritten when detection returns null.
    • The IP refresh happens after pg_restore has run.
  • pnpm --filter=@dokploy/server typecheck passes.
  • biome check clean on the changed files.
  • Full related suite (__test__/restore, __test__/wss/utils, __test__/utils/backups) passes — 28/28.
 ✓ __test__/restore/web-server.test.ts (3 tests)
 ✓ __test__/utils/backups.test.ts (9 tests)
 ✓ __test__/wss/utils.test.ts (16 tests)
 Test Files  3 passed (3)
      Tests  28 passed (28)

When restoring a Dokploy web server backup, the database is restored
as-is, which means `webServerSettings.serverIp` keeps the IP of the
machine the backup was taken on. After restoring onto a different host
the dashboard kept showing the old "Server IP".

Re-detect the current host's public IP with `getPublicIpWithFallback`
once the database restore finishes and persist it via
`updateWebServerSettings`, mirroring how the IP is detected during
initial setup. If detection fails the stored value is left untouched
and a warning is emitted so it can be updated manually.

Adds tests covering the success, detection-failure, and ordering cases.
@NoelisTired NoelisTired requested a review from Siumauricio as a code owner June 3, 2026 09:24
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant