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.

Jacek Rozanski Jacek Rozanski Senior PHP/Symfony developer and DevOps engineer with 20+ years of professional experience, running opcode.pl (web development agency, est. 2004). Day job: I'm the sole backend developer at merketing company where I own and maintain 11 PHP/Symfony microservices on AWS (ECS Fargate, RDS, S3, CloudFront), handle the full CI/CD pipeline (Bitbucket Pipelines, Docker), and manage monitoring with Sentry and CloudWatch. These services handle high request volumes in production every month. What I bring to AI-built apps: - I audit and fix security issues (OWASP methodology), performance bottlenecks, and architectural problems in codebases generated by Cursor, Claude Code, Lovable, Bolt, and v0 - I refactor AI-generated prototypes into production-grade applications with proper error handling, testing, and clean architecture (SOLID, DDD, hexagonal architecture) - I set up the infrastructure AI tools don't touch: AWS hosting, CI/CD pipelines, automated deployments, database optimization, monitoring, and alerting - I integrate external services: payment providers, email systems, partner APIs, SSO/auth Tech stack: PHP 8.x, Symfony, React, Next.js, PostgreSQL, MySQL, Docker, AWS (ECS, RDS, S3, SQS/SNS, CloudFront), Terraform, Supabase. I also use AI tools daily (Claude Code, Cursor) in my own workflow, so I understand both the strengths and the gaps in AI-generated code. Based in Poland (CET timezone). Available for async work and calls during EU/US business hours. Mehdi Ben Haddou Mehdi Ben Haddou - Founder of Chessigma (1M+ users) & many small projects - ex Founding Engineer @Uplane (YC F25) - ex Software Engineer @Amazon and @Booking.com Matthew Jordan Matthew Jordan I've been working at a large software company named Kainos for 2 years, and mainly specialise in Platform Engineering. I regularly enjoy working on software products outside of work, and I'm a huge fan of game development using Unity. I personally enjoy Python & C# in my spare time, but I also specialise in multiple different platform-related technologies from my day job. Caio Rodrigues Caio Rodrigues I'm a full-stack developer focused on building practical and scalable web applications. My main experience is with **React, TypeScript, and modern frontend architectures**, where I prioritize clean code, component reusability, and maintainable project structures. I have strong experience working with **dynamic forms, state management (Redux / React Hook Form), and complex data-driven interfaces**. I enjoy solving real-world problems by turning ideas into reliable software that companies can actually use in their daily operations. Beyond coding, I care about **software quality and architecture**, following best practices for componentization, code organization, and performance optimization. I'm also comfortable working across the stack when needed, integrating APIs, handling business logic, and helping transform prototypes into production-ready systems. My goal is always to deliver solutions that are **simple, efficient, and genuinely useful for the people using them.** BurnHavoc BurnHavoc Been around fixing other peoples code for 20 years. Omar Faruk Omar Faruk As a Product Engineer at Klasio, I contributed to end-to-end product development, focusing on scalability, performance, and user experience. My work spanned building and refining core features, developing dynamic website templates, integrating secure and reliable payment gateways, and optimizing the overall system architecture. I played a key role in creating a scalable and maintainable platform to support educators and learners globally. I'm enthusiastic about embracing new challenges and making meaningful contributions. Dor Yaloz Dor Yaloz SW engineer with 6+ years of experience, I worked with React/Node/Python did projects with React+Capacitor.js for ios Supabase expert AUXLE AUXLE I am a Full Stack Developer experienced in building Websites, Web apps and Cross Platform Mobile Apps for Startups and Companies. Luca Liberati Luca Liberati I work on monoliths and microservices, backends and frontends, manage K8s clusters and love to design apps architecture 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/

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