For some sites (like bits.wikimedia.org, kernel.org or google.ru, list will depend on your DNS server and its settings), polipo returns Error 504 Timeout while site itself is running and accessible via any browser without a proxy.
After some investigation it was found, that when polipo receives DNS answer telling that AAAA record does not exist before receiving answer for A record with CNAMEs, it results in timeout.
Excatly the same problem and solution to it is available on Debian bugzilla:
Created attachment 291773 [details]
Created attachment 291775 [details, diff]
Patch from Debian bug #540912 by Stepan Golosunov fixes this problem for me.
+ 02 May 2013; Tom Wijsman <TomWij@gentoo.org>
+ +files/polipo-126.96.36.199-dns-timeout-fix.patch, +polipo-188.8.131.52-r2.ebuild:
+ EAPI 5. Fix incorrect timeout reporting for domains that are available,
+ revision bump. Thanks to Andrew Savchenko for reporting. Fixes bug #389675.