Permission error when starting a LableStudio space

It says

Exit code: 1. Reason: => Database and media directory: /label-studio/data
=> Static URL is set to: /static/
Traceback (most recent call last):
  File "/label-studio/.venv/bin/label-studio", line 3, in <module>
    from label_studio.server import main
  File "/label-studio/label_studio/server.py", line 23, in <module>
    from label_studio.core.argparser import parse_input_args
  File "/label-studio/label_studio/core/argparser.py", line 5, in <module>
    from .settings.base import EXPORT_DIR
  File "/label-studio/label_studio/core/settings/base.py", line 470, in <module>
    os.makedirs(MEDIA_ROOT, exist_ok=True)
  File "<frozen os>", line 225, in makedirs
PermissionError: [Errno 13] Permission denied: '/label-studio/data/media'

When starting up

1 Like

The cause is attempting to write to a directory that is not writable due to permissions. Setting the following environment variable would resolve this.
LABEL_STUDIO_BASE_DATA_DIR=/tmp/label-studio
Any directory with write permissions will work.

That error is pretty straightforward — Label Studio is trying to create its media folder but doesn’t have permission.

Here’s how to fix it:

  1. Check who owns the folder

    ls -ld /label-studio/data
    
    

    If it’s owned by root, Label Studio (running as a different user) can’t write there.

  2. Give yourself permission

    sudo chown -R $USER:$USER /label-studio/data
    
    

    or if you’re running inside Docker, adjust ownership to the container user (often 1001 or label-studio).

  3. Set writable permissions (if quick and dirty):

    sudo chmod -R 777 /label-studio/data
    
    

    This is less safe, but fine for local experiments.

  4. If Dockerized:

    • Mount a local volume that’s writable:

      docker run -it -p 8080:8080 \
        -v $(pwd)/mydata:/label-studio/data \
        heartexlabs/label-studio:latest
      
      
    • Replace $(pwd)/mydata with a folder on your machine you own.

Thanks! It worked!

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.