Claude Code storage

File Write Operations Failing with Permission Errors

Your application fails when trying to write files to disk, throwing EACCES, EPERM, or permission denied errors. File uploads, log writing, cache storage, or report generation all fail because the application process doesn't have write access to the target directories.

This commonly happens when Claude Code generates code that writes to absolute paths like /tmp, /var, or the project root directory, but the deployment environment (Docker container, cloud function, or restricted server) doesn't allow writes to those locations.

The code works perfectly in local development where you run as an admin user, but breaks immediately in production where the application runs as a restricted service account.

Error Messages You Might See

Error: EACCES: permission denied, open '/var/data/output.pdf' EPERM: operation not permitted, mkdir '/app/uploads' OSError: [Errno 13] Permission denied: '/opt/data/cache' Read-only file system
Error: EACCES: permission denied, open '/var/data/output.pdf'EPERM: operation not permitted, mkdir '/app/uploads'OSError: [Errno 13] Permission denied: '/opt/data/cache'Read-only file system

Common Causes

  • Hardcoded absolute paths — Code writes to /tmp or /var/data which may be read-only in containerized environments
  • Read-only filesystem in serverless — Cloud functions and some container runtimes have read-only root filesystems
  • Docker container running as non-root — The application user inside the container doesn't own the target directory
  • Missing directory creation — Code tries to write a file before creating its parent directory
  • SELinux or AppArmor restrictions — Security modules blocking file writes even when Unix permissions allow them

How to Fix It

  1. Use os.tmpdir() or platform-agnostic paths — Replace hardcoded paths with Node's os.tmpdir() or Python's tempfile.gettempdir()
  2. Create directories before writing — Always call fs.mkdirSync(dir, {recursive: true}) or os.makedirs(dir, exist_ok=True) before file operations
  3. Use /tmp in serverless — In AWS Lambda or similar, /tmp is the only writable directory. Configure your app to use it
  4. Set correct Docker permissions — Add RUN chown -R appuser:appuser /app/data in your Dockerfile for writable directories
  5. Use object storage for production — Replace local file writes with S3, GCS, or Supabase Storage for production deployments

Real developers can help you.

Daniel Vázquez Daniel Vázquez Software Engineer with over 10 years of experience on Startups, Government, big tech industry & consulting. Taufan Taufan I’m a product-focused engineer and tech leader who builds scalable systems and turns ideas into production-ready platforms. Over the past years, I’ve worked across startups and fast-moving teams, leading backend architecture, improving system reliability, and shipping products used by thousands of users. My strength is not just writing code — but connecting product vision, technical execution, and business impact. Vlad Temian Vlad Temian 15+ years shipping production infrastructure for startups. Former CTO at qed.builders (acquired by The Sandbox). Cursor ambassador and agentic tooling builder. I've scaled systems, automated deployments, and built observability tools for AI coding workflows. I specialize in taking vibe-coded apps from broken prototype to production-ready: fixing Supabase auth/RLS, Stripe integrations, deployment pipelines, and cleaning up AI-generated spaghetti. I build tools in this space (agentprobe, claudebin, micode) and understand both sides: how AI generates code and why it breaks. https://blog.vtemian.com/ PawelPloszaj PawelPloszaj I'm fronted developer with 10+ years of experience with big projects. I have small backend background too Luca Liberati Luca Liberati I work on monoliths and microservices, backends and frontends, manage K8s clusters and love to design apps architecture Richard McSorley Richard McSorley Full-Stack Software Engineer with 8+ years building high-performance applications for enterprise clients. Shipped production systems at Walmart (4,000+ stores), Cigna (20M+ users), and Arkansas Blue Cross. 5 patents in retail/supply chain tech. Currently focused on AI integrations, automation tools, and TypeScript-first architectures. Rudra Bhikadiya Rudra Bhikadiya I build and fix web apps across Next.js, Node.js, and DBs. Comfortable jumping into messy code, broken APIs, and mysterious bugs. If your project works in theory but not in reality, I help close that gap. Milan Surelia Milan Surelia Milan Surelia is a Mobile App Developer with 5+ years of experience crafting scalable, cross-platform apps at 7Span and Meticha. At 7Span, he engineers feature-rich Flutter apps with smooth performance and modern UI. As the Co-Founder of Meticha, he builds open-source tools and developer-focused products that solve real-world problems. Expertise: 💡 Developing cross-platform apps using Flutter, Dart, and Jetpack Compose for Android, iOS, and Web. 🖋️ Sharing insights through technical writing, blogging, and open-source contributions. 🤝 Collaborating closely with designers, PMs, and developers to build seamless mobile experiences. Notable Achievements: 🎯 Revamped the Vepaar app into Vepaar Store & CRM with a 2x performance boost and smoother UX. 🚀 Launched Compose101 — a Jetpack Compose starter kit to speed up Android development. 🌟 Open source contributions on Github & StackOverflow for Flutter & Dart 🎖️ Worked on improving app performance and user experience with smart solutions. Milan is always happy to connect, work on new ideas, and explore the latest in technology. hanson1014 hanson1014 Full-stack developer experienced in fixing and deploying AI-generated apps from Lovable, Bolt.new, Cursor, and Replit. I specialize in debugging Supabase integration issues (auth flows, RLS policies, database connections), fixing broken deployments, resolving routing/blank screen problems, and cleaning up messy React/Vite codebases. I also build production apps with the Claude API and have shipped a Mac desktop dev tool (Nexterm from scratch. Based in Hong Kong, fast turnaround. Jaime Orts-Caroff Jaime Orts-Caroff I'm a Senior Android developer, open to work in various fields

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help

Frequently Asked Questions

Why does file writing work locally but not in production?

Local development typically runs as your user with full permissions. Production environments (Docker, serverless, cloud VMs) run as restricted users with limited filesystem access. Always use platform-appropriate writable directories.

Where can I write files in AWS Lambda?

Only the /tmp directory is writable in Lambda, with a 512MB limit (configurable up to 10GB). For persistent storage, upload to S3 instead of writing locally.

Related Claude Code Issues

Can't fix it yourself?
Real developers can help.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help