Varnish service not starting due to Error: Cannot create working directory

Written by - 0 comments

Published on - Listed in Varnish Linux


After switching from the free Varnish Cache to Varnish Enterprise (a.k.a. Varnish-Plus) version, there were still two Varnish shown on a Ubuntu server:

root@ubuntu:~# dpkg -l|grep varnish
rc  varnish                                6.0.5-1~bionic
ii  varnish-plus                           6.0.11r3-1~jammy

The varnish package is the open source package, which was removed when varnish-plus (Varnish Enterprise) was installed. However the package was not purged yet. Let's purge the removed varnish package so our dpkg list only shows the active Varnish package:

root@ubuntu:~# apt-get purge varnish

But after doing this, the Varnish service(s) cannot be started anymore and show the following error:

root@ubuntu:~# systemctl restart varnish-instance
Job for varnish-instance.service failed because the control process exited with error code.
See "systemctl status varnish-instance.service" and "journalctl -xeu varnish-instance.service" for details.
root@ubuntu:~# journalctl -xeu varnish-instance.service
Jun 29 11:53:51 ubuntu varnishd[2755]: Opening environment 'mse'
Jun 29 11:53:51 ubuntu varnishd[2755]: Environment 'mse' opened successfully
Jun 29 11:53:51 ubuntu varnishd[2755]: Error: Cannot create working directory '/var/lib/varnish/varnish-instance/': No such file or directory
Jun 29 11:53:51 ubuntu varnishd[2755]: Error: Cannot create working directory (/var/lib/varnish/varnish-instance/): Success
Jun 29 11:53:51 ubuntu varnishd[2755]: (-? gives usage)
Jun 29 11:53:51 ubuntu varnishd[2755]: Cannot create working directory '/var/lib/varnish/varnish-instance/': No such file or directory
Jun 29 11:53:51 ubuntu systemd[1]: varnish-instance.service: Control process exited, code=exited, status=255/EXCEPTION

By purging the Varnish Cache package (varnish), the working directory /var/lib/varnish was removed. The problem? Both free Varnish Cache and the licensed Varnish Enterprise packages use the same path as working directory.

To fix this, we can reinstall the varnish-plus package. This re-creates all the default configuration files and needed directories:

root@ubuntu:~# apt-get install --reinstall varnish-plus
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 0 B/6,400 kB of archives.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 147421 files and directories currently installed.)
Preparing to unpack .../varnish-plus_6.0.11r3-1~jammy_amd64.deb ...
Unpacking varnish-plus (6.0.11r3-1~jammy) over (6.0.11r3-1~jammy) ...
Setting up varnish-plus (6.0.11r3-1~jammy) ...
Created symlink /etc/systemd/system/multi-user.target.wants/varnish.service -> /lib/systemd/system/varnish.service.

Starting the Varnish instance(s) now works again:

root@ubuntu:~# systemctl restart varnish-instance
root@ubuntu:~# systemctl status varnish-instance
- varnish-instance.service - Varnish Instance varnish-instance
     Loaded: loaded (/etc/systemd/system/varnish-instance.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2023-06-29 11:54:50 CEST; 12s ago
[...]


Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   OpenSearch   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder