I have been trying to get squid to work. I have a configuration for the cache to be created in the directory /var/cache/squid3/. However, I get this error when running squid with the "-z" tag (It is the first run):

WARNING: Cannot write log file: /var/log/squid3/cache.log
/var/log/squid3/cache.log: Permission denied
 messages will be sent to 'stderr'.
2015/05/23 20:05:39 kid1| Creating missing swap directories
2015/05/23 20:05:39 kid1| /var/cache/squid3 exists
FATAL: Failed to make swap directory /var/cache/squid3/00: (13)
Permission denied
Squid Cache (Version 3.3.8): Terminated abnormally.
CPU Usage: 0.010 seconds = 0.007 user + 0.003 sys
Maximum Resident Size: 22560 KB
Page faults with physical i/o: 0

I tried to fix this with typing sudo chmod 755 /var/cache/squid3, however also without any success.

The output of namei -l /var/cache/squid3 is:

$ namei -l /var/cache/squid3
f: /var/cache/squid3
drwxr-xr-x root root /
drwxr-xr-x root root var
drwxr-xr-x root root cache
drwxr-xr-x root root squid3

UPDATE: I made new directories in /squid3_log and /squid3_cache. I then issued for both:

sudo chown -R root:proxy /squid3_log #and squid3_cache


sudo chmod -R 777 /squid3_log #and squid3_cache

It fixed the permission denied with squid3_cache but not with squid3_log.

UPDATE: I tried purging, reinstalling, reconfiguring and it worked with first run squid3 -z. But then when I ran the debug squid3 -NCd1, It showed:

2015/06/01 16:24:24| Starting Squid Cache version 3.3.8 for x86_64-pc-linux-gnu...
2015/06/01 16:24:24| Process ID 20379
2015/06/01 16:24:24| Process Roles: master worker
2015/06/01 16:24:24| With 65536 file descriptors available
2015/06/01 16:24:24| Initializing IP Cache...
2015/06/01 16:24:24| DNS Socket created at [::], FD 5
2015/06/01 16:24:24| DNS Socket created at, FD 6
2015/06/01 16:24:24| Adding nameserver from /etc/resolv.conf
2015/06/01 16:24:24| Adding domain Home from /etc/resolv.conf
2015/06/01 16:24:24| Logfile: opening log /home/john/squid3_log/access.log
2015/06/01 16:24:24| WARNING: log parameters now start with a module name. Use 'stdio:/home/john/squid3_log/access.log'
2015/06/01 16:24:24| WARNING: no_suid: setuid(0): (1) Operation not permitted
2015/06/01 16:24:25| Unlinkd pipe opened on FD 11
2015/06/01 16:24:25| Local cache digest enabled; rebuild/rewrite every 3600/3600 sec
2015/06/01 16:24:25| Logfile: opening log /home/john/squid3_log/store.log
2015/06/01 16:24:25| WARNING: log parameters now start with a module name. Use 'stdio:/home/john/squid3_log/store.log'
2015/06/01 16:24:25| Swap maxSize 15360000 + 16384 KB, estimated 1182798 objects
2015/06/01 16:24:25| Target number of buckets: 59139
2015/06/01 16:24:25| Using 65536 Store buckets
2015/06/01 16:24:25| Max Mem  size: 16384 KB
2015/06/01 16:24:25| Max Swap size: 15360000 KB
2015/06/01 16:24:25| Rebuilding storage in /home/john/squid3_cache (no log)
2015/06/01 16:24:25| Using Least Load store dir selection
2015/06/01 16:24:25| Current Directory is /home/john
2015/06/01 16:24:25| Loaded Icons.
2015/06/01 16:24:25| HTCP Disabled.
2015/06/01 16:24:25| Sending SNMP messages from [::]:3129
2015/06/01 16:24:25| WARNING: no_suid: setuid(0): (1) Operation not permitted
2015/06/01 16:24:25| Pinger socket opened on FD 17
2015/06/01 16:24:25| /var/run/squid3.pid: (13) Permission denied
2015/06/01 16:24:25| Closing HTTP port [::]:3128
FATAL: Could not write pid file
Aborted (core dumped)

I am using Ubuntu 14.04 LTS (Trusty Tahr) and the latest version of Squid3

  • Please edit your question and add the output of namei -l /var/cache/squid3
    – heemayl
    May 23, 2015 at 18:26
  • @heemayl I have edited it. And as I can see, all is root, and one is squid3? I have no idea what it means
    – John K
    May 23, 2015 at 19:04
  • Check my answer.
    – heemayl
    May 23, 2015 at 19:17

3 Answers 3


squid3 runs as the user proxy, so you set the owner user (and group) as proxy and then set permissions accordingly.

You can do the following to change recursively the owner and owner group of all files under /var/cache/squid3 to user proxy and group proxy respectively:

sudo chown -R proxy:proxy /var/cache/squid3 

Also make sure the owner has the right permission, the permission you currently have i.e. 0755 will do.

In your case, as you can see the directory /var/cache/squid3 is only writable by root, hence you were getting the permission denied error.

  • thanks, but it did not fix. And sorry for the super late reply
    – John K
    May 31, 2015 at 12:49

In my case (Ubuntu 16.04, Squid 3.5.12), the problem is in standard AppArmor rules and non-standard cache directory, look into /var/log/syslog:

Sep 26 23:08:34 server2 kernel: [ 6458.643201] audit: type=1400 audit(1506449314.016:36): apparmor="DENIED" operation="mkdir" profile="/usr/sbin/squid" name="/BIG/squid_spool/00/00/" pid=4377 comm="squid" requested_mask="c" denied_mask="c" fsuid=13 ouid=13

Symlinks doesn't works in this case too.

Possibility solutions:

  • Change option cache_dir to standard /var/spool/squid and not use symlinks in this path;
  • Change file /etc/apparmor.d/usr.sbin.squid and reload apparmor:

    sudo apparmor_parser -r /etc/apparmor.d/usr.sbin.squid

    But you may have small problems on updates.

  • Mount separate partition for Squid cache.

change owner to proxy for your installed directory sudo chown proxy:proxy /usr/local/squid -R and set proxy user in squid.conf

vi /usr/local/squid/etc/squid.conf cache_effective_user proxy

Then restart the squid, your permission denied issue gone and WARNING: Cannot write log file also resolved.

I have tested in ubuntu 14.x of my system and then comment here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.