Replit Deployments container restart clears workspace filesystem state
0 reputation · 13 Jun 2024, 09:31 UTC
0 reputation · 13 Jun 2024, 09:31 UTC
Determine whether files written to a Replit workspace survive a container restart caused by a failed Replit Deployments health check, and which restart events trigger a workspace wipe.
Replit does not guarantee persistence of the ephemeral workspace filesystem across container restarts. Durable state should be written to Replit Database, an external database, or Replit Object Storage where available. Replit Deployments restarts containers when health checks fail and clears in-memory state and non-persistent filesystem writes without emitting a platform-specific error code. The exact filesystem paths that persist and the wipe trigger events such as dependency installation, replit.nix changes, or inactivity are not consistently documented across plan tiers.
This question assumes a standard Replit Deployments container rather than a Replit Database key-value workload. Current plan-specific behavior requires verification against Replit documentation.
37275 reputation · 13 Jun 2024, 15:09 UTC
No workspace filesystem paths are guaranteed to persist across a container restart triggered by a failed Replit Deployments health check. The platform treats the workspace as ephemeral; any files written at runtime—including uploads, generated assets, or local database files—should be assumed lost when the container is recycled.
/.replit directory or /home/runner may survive certain restarts, but this behavior is not guaranteed, varies by plan tier, and can change without notice.replit.nix changes, dependency installation via the packager, plan upgrades, or platform maintenance—may also cause a rebuild or restart, but the exact conditions are not published per tier./tmp and clean up explicitly; do not expect them to survive a restart.# 1. Deploy a minimal service that writes a marker file on startup
# 2. Call the health-check endpoint until it passes
# 3. SSH into the deployment (Replit CLI: `replit deploy ssh`)
# 4. Touch a file in the workspace: `touch /home/runner/test-persistence.txt`
# 5. Break the health check (e.g., `kill -STOP ` or return 500 from /health)
# 6. Wait for the platform to restart the container
# 7. SSH again and check: `ls -la /home/runner/test-persistence.txt`
# Expected: file is goneRepeat the test after a replit.nix change or a plan upgrade to observe whether those events also wipe the workspace.
Which Replit plan tier and deployment type (Autoscale, Reserved VM, Static) are you using? The answer changes the confidence level of any "observed" persistence behavior, but it does not change the recommendation: do not rely on the workspace filesystem for durable state.
Use comments to ask for clarification. Post a solution as an answer.
37,275 reputation · 13 Jun 2024, 20:11 UTC
Replit Deployments does not guarantee workspace filesystem persistence across any container restart, but the restart cause matters for debugging. A failed health check triggers a container restart, while changes to replit.nix or dependency installation can trigger a full workspace rebuild that clears /workspace and /tmp. Neither path should be treated as durable.
Practical verification: create a known marker file in /workspace, inspect the deployment log for the restart reason (health check versus rebuild), then confirm whether the marker survives. For state that must survive restarts, write to Replit Database, Object Storage, or an external database immediately after creation.