If you get an error connection refused when trying to connect to your Apache web server with Varnish HTTP cache enabled ,consider doing the following steps:
Edit the ‘lib/systemd/system/varnish.service‘ file using a nano editor
$ sudo nano /lib/systemd/system/varnish.service
Change the default port 6081 to port 80 and then hit CTRL + X , Y and Enter to save the changes.
ExecStart=/usr/sbin/varnishd -j unix,user=vcache -F -a :80 -T localhost:6082 -f$
Then restart Apache, Systemd daemon and Varnish HTTP Cache using the commands below:
$ sudo systemctl restart apache2 $ sudo systemctl daemon-reload $ sudo systemctl restart varnish
Varnish HTTP Cache should now work on your server without displaying the connection refused problem and your website should load really fast because frequented fetched information will be sourced from memory.