Permission Denied

Fix permission denied errors in Moltbot.

Permission Denied

Getting "permission denied" or "access denied" errors? Here's how to fix them.

Symptoms

Error: EACCES: permission denied, open '/app/data/config.json'

or

PermissionError: [Errno 13] Permission denied

Likely Causes

  1. Docker volume permissions - mounted volumes have wrong ownership
  2. File system permissions - files not readable/writable
  3. API permissions - bot lacks required permissions
  4. Skill permissions - skill trying to access unauthorized resources

Fix Steps

Docker Volume Permissions

Option 1: Match container user

# Find the container's user ID
docker exec moltbot id
# Usually uid=1000 or uid=node

# Set ownership on host
sudo chown -R 1000:1000 ./data

Option 2: Use Docker's user flag

# docker-compose.yml
services:
  moltbot:
    user: "${UID}:${GID}"
    volumes:
      - ./data:/app/data

Option 3: More permissive (dev only)

chmod -R 777 ./data  # NOT for production!

File System Permissions

# Check current permissions
ls -la /path/to/file

# Fix ownership
sudo chown $USER:$USER /path/to/file

# Fix permissions (read/write for owner)
chmod 644 /path/to/file

# For directories
chmod 755 /path/to/directory

API Permissions (Telegram)

Ensure your bot has the right permissions:

  1. Go to @BotFather
  2. Send /mybots
  3. Select your bot
  4. Check "Bot Settings" → "Group Privacy"

For group messages, you may need to:

  • Disable privacy mode
  • Make bot an admin

API Permissions (Discord)

  1. Go to Discord Developer Portal
  2. Select your application
  3. Go to OAuth2 → URL Generator
  4. Ensure required permissions are selected
  5. Re-invite bot with new permissions

Skill Permissions

If a skill is denied access:

# Check skill configuration
cat .env | grep SKILL_

# Enable specific skill permissions
SKILL_FILE_ACCESS=true
SKILL_FILE_PATHS=/home/user/allowed-dir

Verify

After fixing:

# Test file access
docker exec moltbot ls -la /app/data

# Test write access
docker exec moltbot touch /app/data/test && echo "Write OK"

Prevent

  • Plan volume permissions before deployment
  • Use named Docker volumes for automatic management
  • Document required bot permissions
  • Use least privilege principle