Permission Denied When Writing Files
Application attempts to write files (logs, uploads, caches) but fails with permission denied errors. The user running the application doesn't have write permissions to the target directory. Works in development where user has full permissions but fails in production.
This commonly occurs with log files, uploaded files, or temporary cache directories.
Error Messages You Might See
Common Causes
- Target directory owned by different user, application user lacks write permission
- Directory permissions too restrictive (755 prevents write by non-owner)
- Parent directory doesn't have execute bit, preventing access to subdirectories
- SELinux or AppArmor policies blocking file access
- Disk full, preventing new writes despite having permissions
How to Fix It
Check permissions: ls -la /path/to/dir. Change if needed: chmod 755 or chown to correct user. Ensure application user is owner or in group: chown app:app /logs. Create directories with correct permissions at startup. Use world-writable temp directories (/tmp) if needed. Run with sudo or correct user: sudo -u app java -jar app.jar
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
How to check file permissions?
ls -l shows permissions: rwx for owner, group, others. First digit (1-9) is: d (dir), r (read), w (write), x (execute).
How to fix permission denied?
Change ownership: sudo chown app:app /path. Change permissions: chmod 755 /path. Format: chmod u+rw,g+r,o+r /path
What user should own application directories?
Create dedicated user (app). Change directory ownership: chown -R app:app /app. Run with that user: sudo -u app