1

I try to clone a project to which was running on nginx and using varnish.

I try to run it on apache2.

I get this error:

report.CRITICAL: No cache server(s) could be purged Cache host: company.vm:80resulted in error message: Unable to connect to company.vm:80 . Error #0: stream_socket_client(): unable to connect to company.vm:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) {"method":"GET","url":"http:/","invalidateInfo":{"servers":["[object] (Laminas\Uri\Http: http://company.vm/)"],"formattedTagsChunk":".*"}} []

I have no experience with varnish. How to get rid of this error?

Do I need to disable modules?

4 Answers 4

1

I was able to disable varnish by executing this command which resets the cache application to the magento build in method.

php bin/magento config:set system/full_page_cache/caching_application 1
0

That error means you are not setting the cache server (host) correctly.
Please take a look at the Magento official document then make sure varnish is installed and is running, and set the correct config for host and port.
https://devdocs.magento.com/guides/v2.4/config-guide/varnish/use-varnish-cache.html#configure-magento-to-purge-varnish

And you also can take a look at the code: vendor/magento/module-cache-invalidate/Model/PurgeCache.php, sendPurgeRequestToServers method.

0

See https://www.varnish-software.com/developers/tutorials/configuring-varnish-magento/#6-making-cache-purges-work for a tutorial on how to register Varnish so that Magento knows which endpoints to call when the caches needs to be purged.

Here's an example where Varnish is hosted on the same machine as your Magento setup and is listening on port 80:

bin/magento setup:config:set --http-cache-hosts=localhost

Here's an example where Varnish is hosted on another machine (server 10.20.30.40 on port 1234):

bin/magento setup:config:set --http-cache-hosts=10.20.30.40:1234

Once the Varnish endpoint is registered, Magento can successfully call that endpoint to purge items from the cache.

0

The error simply coveys the message to set the varnish cache server (host) and tries to host on port no 80. You need to configure the Varnish setting and update the file.

Set the host on the same machine as your Magento setup and listen on port 80:

bin/magento setup:config:set --http-cache-hosts=127.0.0.1

or

bin/magento setup:config:set --http-cache-hosts=localhost

Check the full documentation:
https://devdocs.magento.com/guides/v2.4/config-guide/varnish/use-varnish-cache.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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