Squid 4.1 unable to create listeners

squid

I am trying to set up a Squid transparent proxy.

When starting squid, it starts up with exit code 0 and appears to be running. However, no tcp listeners are created (though there seems to be some UDP listeners).

Digging into the logs, I spotted the following pattern:

Jan 31 09:30:40 proxy squid[6060]: Beginning Validation Procedure
Jan 31 09:30:40 proxy squid[6060]: Closing HTTP(S) port [::]:3128
Jan 31 09:30:40 proxy squid[6060]: Closing HTTP(S) port [::]:3129
Jan 31 09:30:40 proxy squid[6060]: Closing HTTP(S) port [::]:3130
Jan 31 09:30:40 proxy squid[6060]: Not currently OK to rewrite swap log.
Jan 31 09:30:40 proxy squid[6060]: storeDirWriteCleanLogs: Operation aborted.
Jan 31 09:30:40 proxy squid[6060]: FATAL: Failed to rename log file /var/spool/squid/swap.state.new to /var/spool/squid/swap.state
Jan 31 09:30:40 proxy squid[6060]: Squid Cache (Version 4.1): Terminated abnormally.
Jan 31 09:30:40 proxy squid[6043]: Squid Parent: squid-1 process 6060 exited with status 1
Jan 31 09:30:40 proxy squid[6043]: Squid Parent: (squid-1) process 6064 started
Jan 31 09:30:40 proxy squid[6064]: Set Current Directory to /var/spool/squid
Jan 31 09:30:40 proxy squid[6064]: Starting Squid Cache version 4.1 for x86_64-pc-linux-gnu...
Jan 31 09:30:40 proxy squid[6064]: Service Name: squid
Jan 31 09:30:40 proxy squid[6064]: Process ID 6064
Jan 31 09:30:40 proxy squid[6064]: Process Roles: worker
Jan 31 09:30:40 proxy squid[6064]: With 1024 file descriptors available
Jan 31 09:30:40 proxy squid[6064]: Initializing IP Cache...
Jan 31 09:30:40 proxy squid[6064]: DNS Socket created at [::], FD 5
Jan 31 09:30:40 proxy squid[6064]: DNS Socket created at 0.0.0.0, FD 14
Jan 31 09:30:40 proxy squid[6064]: Logfile: opening log daemon:/var/log/squid/access.log
Jan 31 09:30:40 proxy squid[6064]: Logfile Daemon: opening log /var/log/squid/access.log
Jan 31 09:30:40 proxy squid[6064]: Store logging disabled
Jan 31 09:30:40 proxy squid[6064]: WARNING: disk-cache maximum object size is too large for mem-cache: 4096.00 KB > 512.00 KB
Jan 31 09:30:40 proxy squid[6064]: Swap maxSize 5120000 + 524288 KB, estimated 434176 objects
Jan 31 09:30:40 proxy squid[6064]: Target number of buckets: 21708
Jan 31 09:30:40 proxy squid[6064]: Using 32768 Store buckets
Jan 31 09:30:40 proxy squid[6064]: Max Mem  size: 524288 KB [shared]
Jan 31 09:30:40 proxy squid[6064]: Max Swap size: 5120000 KB
Jan 31 09:30:40 proxy squid[6064]: Rebuilding storage in /var/spool/squid (dirty log)
Jan 31 09:30:40 proxy squid[6064]: Using Least Load store dir selection
Jan 31 09:30:40 proxy squid[6064]: Set Current Directory to /var/spool/squid
Jan 31 09:30:40 proxy squid[6064]: Finished loading MIME types and icons.
Jan 31 09:30:40 proxy squid[6064]: HTCP Disabled.
Jan 31 09:30:40 proxy squid[6064]: commBind Cannot bind socket FD 24 to [::1]: (99) Cannot assign requested address
Jan 31 09:30:40 proxy squid[6064]: commBind Cannot bind socket FD 25 to [::1]: (99) Cannot assign requested address
Jan 31 09:30:40 proxy squid[6064]: ERROR: Failed to create helper child read FD: UDP[::1]
Jan 31 09:30:40 proxy squid[6064]: Squid plugin modules loaded: 0
Jan 31 09:30:40 proxy squid[6064]: Adaptation support is off.
Jan 31 09:30:40 proxy squid[6064]: commBind Cannot bind socket FD 24 to [::]: (2) No such file or directory
Jan 31 09:30:40 proxy squid[6064]: Done reading /var/spool/squid swaplog (0 entries)
Jan 31 09:30:40 proxy squid[6064]: Store rebuilding is 0.00% complete
Jan 31 09:30:40 proxy squid[6064]: Finished rebuilding storage from disk.
Jan 31 09:30:40 proxy squid[6064]: 0 Entries scanned
Jan 31 09:30:40 proxy squid[6064]: 0 Invalid entries.
Jan 31 09:30:40 proxy squid[6064]: 0 With invalid flags.
Jan 31 09:30:40 proxy squid[6064]: 0 Objects loaded.
Jan 31 09:30:40 proxy squid[6064]: 0 Objects expired.
Jan 31 09:30:40 proxy squid[6064]: 0 Objects cancelled.
Jan 31 09:30:40 proxy squid[6064]: 0 Duplicate URLs purged.
Jan 31 09:30:40 proxy squid[6064]: 0 Swapfile clashes avoided.
Jan 31 09:30:40 proxy squid[6064]: Took 0.02 seconds (  0.00 objects/sec).
Jan 31 09:30:40 proxy squid[6064]: Beginning Validation Procedure
Jan 31 09:30:40 proxy squid[6064]: Completed Validation Procedure
Jan 31 09:30:40 proxy squid[6064]: Validated 0 Entries
Jan 31 09:30:40 proxy squid[6064]: store_swap_size = 0.00 KB
Jan 31 09:30:41 proxy squid[6046]: storeLateRelease: released 0 objects
Jan 31 09:30:41 proxy squid[6058]: storeLateRelease: released 0 objects
Jan 31 09:30:41 proxy squid[6064]: storeLateRelease: released 0 objects

Could it be the following line which indicates the issue?

FATAL: Failed to rename log file /var/spool/squid/swap.state.new to /var/spool/squid/swap.state

I checked the directory and the swap.state file seems to have been created succesfully by squid and permissions are set correctly in the entire directory.

My config looks as followed:

visible_hostname squid
acl localnet src 10.0.0.0/8   


workers 3
http_port 3128
http_port 3129 intercept
acl allowed_http_websites dstdomain "/etc/squid/allowed.txt" 
http_access allow allowed_http_websites

http_access deny all

cache_dir aufs /var/spool/squid 5000 16 256

coredump_dir /var/spool/squid

refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern .               0       20%     4320

EDIT:

It most likely has something to do with permissions since running it in no-daemon mode (as root) does have the desired effect. The permissions do seem to be correct as user 'squid' is the owner of the directory with all permissions.

EDIT2:

Running Squid on foreground with the -N option (master only) seems to work. However, running it with –foreground gives the same error.

Best Answer

I found the problem. Somehow, the kids that were spawned seemed to be tripping over each other. Removing the 'workers 3' line in my config solved this issue.