1

I have installed polipo-1.1.1 caching proxy on my OS X 10.11.4 with homebrew:

brew install polipo --with-large-chunks

Sometimes opening URLs (this page for example) is failed with this error message:

504 Connect to apple.stackexchange.com:80 failed: Too many open files

The following error occurred while trying to access https://apple.stackexchange.com/questions/114514/can-the-default-permissions-on-dev-disk-be-changed:

504 Connect to apple.stackexchange.com:80 failed: Too many open files

Generated Sun, 22 May 2016 12:36:56 IRDT by Polipo on Hamids-MacBook-Pro.local:8123.

I have set up ~/.polipo file as configuration file with socksParentProxy and socksProxyType parameters only.

The value of ulimit -n is 4864.

In /usr/local/var/cache/polipo I have 510 folders and total size of this folders is 297 MB.

Total number of files that are open with polipo with this command is 219:

lsof -p $(pgrep polipo) | wc -l

Why this error is occurred and how can I prevent that?

Is there any configurations that I missed to set up?

1

This is a quick fix answer. If you know which configurations caused this problem please post your answer

I didn't find out why this error occurs, but I solve the problem every time this error appears by running this command:

$ brew services restart polipo
Stopping `polipo`... (might take a while)
==> Successfully stopped `polipo` (label: homebrew.mxcl.polipo)
==> Successfully started `polipo` (label: homebrew.mxcl.polipo)

After restarting polipo instance, that error disappears.

NOTE: This command should be executed OUT of a tmux session. In a tmux session it will not work:

$ brew services restart polipo
~/Library/LaunchAgents/homebrew.mxcl.polipo.plist: Operation not permitted
==> Successfully started `polipo` (label: homebrew.mxcl.polipo)

If you are running such a session, detach the session with control+b (or any prefix key combination you set) and then press d. Now run that command.

THE BEST ALTERNATIVE: I used reattach-to-user-namespace to restart polipo service directly from tmux session:

$ brew install reattach-to-user-namespace

then brew services will work.

UPDATE: I found that my local polipo cache size is enough large:

$ du -d0 -h /usr/local/var/cache/polipo
13.8G    /usr/local/var/cache/polipo

There is a "purge" function that is explained here:

The behavior of the -x flag is controlled by three configuration variables. The variable diskCacheUnlinkTime specifies the time during which an on-disk entry should remain unused before it is eligible for removal; it defaults to 32 days.

So I stopped polipo daemon with brew services:

$ brew services stop polipo
$ polipo -x
$ brew services start polipo

Now the size of local cache is reduced:

$ du -d0 -h /usr/local/var/cache/polipo
2.1G    /usr/local/var/cache/polipo

And it seems that the error is gone.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .