Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

PetroGromovo's avatar

Why I got error Permission denied in lavavel sail app and cannot fix them?

I try to run laravel with docker sail and on sail command have output :

$ ./vendor/bin/sail up
[+] Running 7/0
✔ Container projectname-minio-1         Running                                                                                                                                                                                                                        0.0s
✔ Container projectname-clickhouse-1    Created                                                                                                                                                                                                                        0.0s
✔ Container projectname-mysql-1         Running                                                                                                                                                                                                                        0.0s
✔ Container projectname-redis-1         Running                                                                                                                                                                                                                        0.0s
✔ Container projectname-mailpit-1       Created                                                                                                                                                                                                                        0.0s
✔ Container projectname-laravel.test-1  Running                                                                                                                                                                                                                        0.0s
✔ Container projectname-nginx-1         Created                                                                                                                                                                                                                        0.0s
Attaching to clickhouse-1, laravel.test-1, mailpit-1, minio-1, mysql-1, nginx-1, redis-1
nginx-1         | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
nginx-1         | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
nginx-1         | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
nginx-1         | 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
nginx-1         | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf differs from the packaged version
nginx-1         | /docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
nginx-1         | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
mailpit-1       | time="2025/01/18 08:32:02" level=info msg="[smtpd] starting on [::]:1025 (no encryption)"
mailpit-1       | time="2025/01/18 08:32:02" level=info msg="[http] starting on [::]:8025"
mailpit-1       | time="2025/01/18 08:32:02" level=info msg="[http] accessible via http://localhost:8025/"
nginx-1         | 20-envsubst-on-templates.sh: Running envsubst on /etc/nginx/templates/default.conf.template to /etc/nginx/conf.d/default.conf
nginx-1         | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
nginx-1         | /docker-entrypoint.sh: Launching /docker-entrypoint.d/99-generate-ssl-cert.sh
nginx-1         | 99-generate-ssl-cert.sh: Server certificate already exists, do nothing.
nginx-1         | /docker-entrypoint.sh: Configuration complete; ready for start up
nginx-1         | 2025/01/18 08:32:02 [notice] 1#1: using the "epoll" event method
nginx-1         | 2025/01/18 08:32:02 [notice] 1#1: nginx/1.27.3
nginx-1         | 2025/01/18 08:32:02 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
nginx-1         | 2025/01/18 08:32:02 [notice] 1#1: OS: Linux 6.8.0-51-generic
nginx-1         | 2025/01/18 08:32:02 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
nginx-1         | 2025/01/18 08:32:02 [notice] 1#1: start worker processes
nginx-1         | 2025/01/18 08:32:02 [notice] 1#1: start worker process 36
nginx-1         | 2025/01/18 08:32:02 [notice] 1#1: start worker process 37
nginx-1         | 2025/01/18 08:32:02 [notice] 1#1: start worker process 38
nginx-1         | 2025/01/18 08:32:02 [notice] 1#1: start worker process 39
clickhouse-1    | ClickHouse Database directory appears to contain a database; Skipping initialization
clickhouse-1    | Processing configuration file '/etc/clickhouse-server/config.xml'.
clickhouse-1    | Merging configuration file '/etc/clickhouse-server/config.d/docker_related_config.xml'.
clickhouse-1    | Logging trace to /var/log/clickhouse-server/clickhouse-server.log
clickhouse-1    | Logging errors to /var/log/clickhouse-server/clickhouse-server.err.log


laravel.test-1  |   2025-01-18 08:32:09 ................................................... ~ 0s
laravel.test-1  |   2025-01-18 08:32:09 ................................................... ~ 1s
laravel.test-1  |   2025-01-18 08:32:10 .................................................. ~ 16s
laravel.test-1  |   2025-01-18 08:32:26 ................................................... ~ 3s
laravel.test-1  |   2025-01-18 08:32:29 .................................................. ~ 47s
laravel.test-1  |   2025-01-18 08:33:15 ................................................... ~ 2s
laravel.test-1  |   2025-01-18 08:33:17 ................................................. ~ 109s
laravel.test-1  |   2025-01-18 08:36:46 ................................................... ~ 0s
laravel.test-1  |   2025-01-18 08:37:21 ................................................... ~ 0s
laravel.test-1  |   2025-01-18 08:36:46 .................................................. ~ 58s
laravel.test-1  |   2025-01-18 08:37:44 .................................................. ~ 25s
laravel.test-1  |   2025-01-18 08:38:08 .................................................. ~ 63s
laravel.test-1  |   2025-01-18 08:40:09 ................................................... ~ 1s

But running url

http://0.0.0.0/

I got error :

There is no existing directory at "/projectpath/storage/logs" and it could not be created: Permission denied

In the browser.

I run in the root of the app :

sudo chmod -R 775 storage
sudo chmod -R ugo+rw storage
chmod -R 775 bootstrap/cache

But Still got the same error?

Googling for decision I check firewall options:

# sudo ufw status verbose
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), deny (routed)
New profiles: skip

To                         Action      From
--                         ------      ----
22/tcp                     ALLOW IN    Anywhere
80,443/tcp (Apache Full)   ALLOW IN    Anywhere
22/tcp (v6)                ALLOW IN    Anywhere (v6)
80,443/tcp (Apache Full (v6)) ALLOW IN    Anywhere (v6)

In my app:

"php": "^8.1",
"laravel/framework": "^10.0",
"laravel/sail": "^1.0",

I do not see why this error and how to fix it ?

0 likes
5 replies
owis-sabry's avatar

try to change the owner first the owner is you and the group server group and make it recursively then change the permission in root file also recursively to be 775 commands : sudo chown -R $user:$group . sudo chmod -R 775 . i hope this solve your problem

1 like
PetroGromovo's avatar

@owis-sabry I run 2 commands in the root of my app :

sudo chown -R $user:$group .
sudo chmod -R 775 storage/logs

without any error messages

I stopped sail console and run one more time :

./vendor/bin/sail up

without errors

But again running in the browser I got error :

storage/logs" and it could not be created: Permission denied
PetroGromovo's avatar

I open storage/logs and check with ls commands:

$ cd storage/logs
$ projectname/storage/logs$ ls -la
total 5
drwxrwxrwx 1 root root    0 jan 18 16:40 .
drwxrwxrwx 1 root root 4096 jan 17 16:16 ..
-rwxrwxrwx 1 root root   14 jan 17 14:56 .gitignore

Have the app some sail-docker user ? How to check his rights ?

PetroGromovo's avatar

I still have the same error : looks like docker in sail container have no access to storage folder of my app

I found https://stackoverflow.com/questions/73476633/laravel-sail-up-throws-permissions-denied-error branch

and try to follow it :

a) as I have :

$ whoami
master

next I run under root :

usermod -a -G docker master

No output.

I check :

$ ls -la storage/logs
total 192
drwxrwxrwx 2 master docker   4096 jan 19 11:19 .
drwxrwxrwx 7 master master   4096 jan 19 11:19 ..
-rwxrwxrwx 1 master docker     14 jan 19 11:13 .gitignore
-rwxrwxrwx 1 master docker 177495 jan 19 12:00 laravel-2025-01-19.log

Looking at next command

chown UbuntuUserName:UbuntuUserGroup -R /path/to/the/laravel/app/storage/logs

I edit it as :

chown master:master -R /var/www/projectname/storage/logs/

Is is valid format I have to run ?

I have next users and groups in my OS:

# compgen -u
root
daemon
bin
sys
sync
games
man
lp
mail
news
uucp
proxy
www-data
backup
list
irc
gnats
nobody
systemd-network
systemd-resolve
messagebus
systemd-timesync
syslog
_apt
tss
uuidd
tcpdump
avahi-autoipd
usbmux
dnsmasq
kernoops
avahi
cups-pk-helper
rtkit
whoopsie
fwupd-refresh
saned
colord
sddm
geoclue
pulse
hplip
master
snapd-range-524288-root
snap_daemon
mysql
redis
nvidia-persistenced


# compgen -g
root
daemon
bin
sys
adm
tty
disk
lp
mail
news
uucp
man
proxy
kmem
dialout
fax
voice
cdrom
floppy
tape
sudo
audio
dip
www-data
backup
operator
list
irc
src
gnats
shadow
utmp
video
sasl
plugdev
staff
games
users
nogroup
systemd-journal
systemd-network
systemd-resolve
crontab
messagebus
systemd-timesync
input
sgx
kvm
render
syslog
tss
bluetooth
ssl-cert
uuidd
tcpdump
_ssh
plocate
avahi-autoipd
netdev
avahi
lpadmin
rtkit
whoopsie
fwupd-refresh
scanner
saned
colord
sddm
geoclue
pulse
pulse-access
lxd
master
sambashare
snapd-range-524288-root
snap_daemon
mysql
docker
redis
nvidia-persistenced

b) I tried to run next command from the branch :

sail root-shell
Command 'sail' not found, but can be installed with:
apt install bsdgames

and

chown -R sail:sail html
chown: invalid user: ‘sail:sail’

Not shure which command must be run here ? I have not installed in my OS? How to check ?

c) I added in my .env :

WWWGROUP=1000
WWWUSER=1000

and next run

sudo ./vendor/bin/sail down --rmi all

with success. But again running :

./vendor/bin/sail up

I had the same error.

I tried to chnage in .env :

WWWGROUP=1001
WWWUSER=1001

anyway the same error.

Which user/group permission do I lack? How to check/fix it ?

Please or to participate in this conversation.