File Uploads Disappearing on Replit
Users upload files through your app — profile pictures, documents, images — and everything appears to work. But after some time, a restart, or a redeployment, all uploaded files are gone. Users see broken image icons and download links that return 404 errors.
The root cause is that your app saves uploaded files to the container's local filesystem, which is ephemeral on Replit. The AI-generated file upload code typically uses multer, formidable, or similar libraries configured to write files to a local /uploads directory.
Even if your app is on Replit's development mode and files seem to persist for a while, they will eventually be lost when the container cycles or you deploy changes.
Error Messages You Might See
Common Causes
- Local disk storage — uploads saved to /uploads or /public/uploads on the ephemeral filesystem
- Multer default config — file upload middleware configured with diskStorage pointing to local directory
- No CDN or cloud storage — the app was not set up with an external file hosting service
- Broken file URLs — files are referenced by local paths that become invalid after restart
- Large files filling disk — uploads consume limited container disk space and trigger cleanup
How to Fix It
- Integrate cloud storage — use AWS S3, Cloudinary, or Supabase Storage to store uploads permanently
- Switch upload middleware — replace multer diskStorage with multer-s3 or a Cloudinary upload stream
- Store URLs in database — save the cloud storage URL in your database instead of a local file path
- Add file size limits — configure maximum upload sizes to prevent disk exhaustion
- Serve files from CDN — use the cloud storage URL directly in your HTML instead of serving from your app
- Migrate existing files — write a one-time script to upload existing local files to cloud storage and update database references
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
Why do uploaded files disappear on Replit?
Replit containers are ephemeral — the filesystem is rebuilt on each deployment. Files saved to disk at runtime are not part of your source code and get deleted.
What is the easiest cloud storage to set up?
Cloudinary is the easiest for images — it has a free tier and a simple upload API. For general files, Supabase Storage is straightforward and also has a free tier.
Can I store small images in the database instead?
Yes, for small files like avatars (under 1MB), you can store them as base64-encoded strings in your database. This is not recommended for larger files.