Writing to a host folder inside a Lima VM fails because it is read-only
A host folder mounted in the Lima VM cannot be written to from inside the VMShort answer
Lima's builtin default for a mount is writable: false, and the default template mounts your home folder read-only. Writes into it from the VM fail. Edit the instance, set writable: true on the mount you need, and restart. Remember the VM's own home directory is not your host home.
Fix it fast
1Find out which cause you have
Open the instance configuration and read the mounts block and the mountType line. Replace default with your instance name.
limactl edit default2Match what you see, then jump to its fix
What does the error look like?
A host folder mounted in the Lima VM cannot be written to from inside the VMContainer or database data directory on a Lima mount fails to write
Cause 1 of 2
The mount is not writable, which is the default
1Check
The Lima default template says the builtin default for writable is false, and the home mount is read-only. Check the entry for the folder you write to.
limactl edit default2Fix
Set writable: true on that mount only, not on a broad folder. Lima discourages writable true with the reverse-sshfs mount type, so prefer 9p or virtiofs where your setup allows.
mounts:
- location: "~/projects"
writable: true3Verify
Restart the instance, then write a file from inside the VM and look for it on the host.
limactl restart default
limactl shell default
# inside the VM:
touch ~/projects/probe.txtConfirmed by raw.githubusercontent.com
Cause 2 of 2
You are writing to the VM's home, not the mounted host home
1Check
The Lima template notes that the user's home inside the VM is not the mounted home directory of the host. A path that matches no mount lives on the VM's own disk and is unrelated to the host folder.
limactl shell default
# inside the VM:
echo $HOME; df -h $HOME2Fix
Work in a path that is listed under mounts, or add the host folder as a mount. Avoid overlapping mounts such as ~ and ~/src, which the template says are not supported.
mounts:
- location: "~/src/my-app"
writable: true3Verify
Create a file in the folder inside the VM and see it on the host.
limactl shell default
# inside the VM:
ls -l ~/src/my-appConfirmed by raw.githubusercontent.com
How do I stop it coming back?
- Mount only the folders a project needs, and make only those writable.
- Keep database data directories on the VM's own disk and mount only source code.
- Do not mount overlapping folders.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Related fixes
Servers
Status code 460 on an AWS Application Load Balancer
elb_status_code 460 in ALB access logs
A 460 is generated by the load balancer, not by your app.
3 causes, each with a fixServers
Application Load Balancer returns 504 for requests to EC2 instances
HTTPCode_ELB_504_Count
A 504 from an Application Load Balancer means it could not get an answer from a target in time.
4 causes, each with a fixServers
apk cannot find py-pip in an Alpine Docker image
py-pip (no such package):
On current Alpine releases there is no package called py-pip.
2 causes, each with a fixServers
dnf cannot install MySQL on Amazon Linux 2023
dnf cannot find a mysql-server package on Amazon Linux 2023
Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.
3 causes, each with a fixServers
ng serve runs in the container but localhost:4200 does not open
The browser cannot open localhost:4200 although ng serve is running in the container
ng serve listens on localhost by default, which inside a container is the container itself.
3 causes, each with a fixServers
Angular routes return 404 from nginx when you refresh or open a link
The home page loads, but refreshing /some/route shows an nginx 404
Angular routes like /users/42 are not files, so nginx looks for them on disk and returns 404.
3 causes, each with a fix