Ubuntu – Squid Proxy Server Error : Upon Starting

PROXYslackwaresquidUbuntuubuntu-18.04

I got this error upon starting Squid Proxy Server using the command sudo squid -z

fatal: ipc::mem::segment::create failed to shm_open(/squid-cf__metadata.shm): 13 permission denied

How shall I fix it? Im using version 3.5.26 of Squid. I tried any fixes I found in the web but nothing works.

I tried implementing the fix below I found in the web:

Just add the following line to your /etc/fstab file: 
shm /dev/shm tmpfs nodev,nosuid,noexec 0 0 
After that use (as root): 
# mount shm 

Unfortunately, it doesn't work. Another possible fix on the web is error reading squid.pid

squid: ERROR: Could not read pid file
/var/run/squid.pid: (13) Permission denied

Unfortunately, as I look in my directory, I could not find squid.pid.

How will I get my Squid working? Thanks.

Best Answer

You've run squid with the wrong user, which created files with wrong permissions.

squid: ERROR: Could not read pid file

You need to run with sudo: sudo squid -z.

fatal: ipc::mem::segment::create failed to shm_open(/squid-cf__metadata.shm): 13 permission denied

You need to remove Squid's .shm files from /dev/shm or assign the right permissions.

$ sudo rm -v /dev/shm/squid*.shm

Also make sure that:

  • Squid's log dir (/var/log/squid?) is owned by the right user (proxy?).
  • Squid's cache dir (/var/spool/squid?) is owned by the right user.

For the full example, check the following Docker container at sameersbn/docker-squid.