PermissionError: [Errno 13] Permission denied: ‘/manage.py’

ubuntu 21.04

I got here searching for PermissionError: [Errno 13] Permission denied: so i’ll just leave this here.

note: the below answer doesn’t work for multi user systems … see this answer instead for another possible solution


If you want to set it and forget it for 1 user, your own user … here’s what I have on my dev machine.

I didn’t own the unix socket, so I chowned it. ( this got it working straight away )

sudo chown $(whoami):$(whoami) /var/run/docker.sock

Another, more permanent solution for your dev environment, is to modify the user ownership of the unix socket creation. This will give your user the ownership, so it’ll stick between restarts:

sudo nano /etc/systemd/system/sockets.target.wants/docker.socket

docker.socket:

[Unit]
Description=Docker Socket for the API

[Socket]
ListenStream=/var/run/docker.sock
SocketMode=0660
SocketUser=YOUR_USERNAME_HERE
SocketGroup=docker

[Install]
WantedBy=sockets.target

Again another less hacky solution: https://stackoverflow.com/a/70124863/2026508

NOTE for WSL ( NevilleLusimba )

might also want to change directory/app ownership to docker

$ sudo chgrp -R docker /path/to/directory 

and give read and write access to docker

$sudo chmod -R g+rw /path/to/directory 

Worked for me on Ubuntu 22.04 LTS via WSL

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)