Configure Varnish (TM) for WordPress

Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and MacOS) or by clicking the shortcut in the Start Menu under “Start -> Bitnami APPNAME Stack -> Application console” (Windows). On OS X VMs, the installation directory is /opt/bitnami and OS X VM users can click the “Open Terminal” button to run commands. Learn more about the Bitnami stack environment and about OS X VMs.

NOTE: The steps below assume that WordPress is already running at the root URL of the server, such as at, and that Varnish (TM) is enabled. Varnish (TM) is disabled by default, but you can enable it by following the instructions in our Varnish (TM) guide.

Download the different files used in the example:


Follow these steps:

  • Load the Bitnami console (Windows, Linux or macOS installers) or log in to the virtual machine console (OS X VM).

  • Backup the Varnish (TM) configuration file:

      $ sudo cp installdir/varnish/etc/varnish/default.vcl installdir/varnish/etc/varnish/default.vcl.backup
  • Add the WordPress-specific Varnish (TM) configuration by executing the following commands:

      $ sudo cp wordpress.vcl installdir/varnish/etc/varnish/default.vcl
      $ sudo sed -i 's/port\s*=\s*"[^"]*"/port = "80"/g' installdir/varnish/etc/varnish/default.vcl
  • Enable and start the Varnish (TM) service.

  • Open port 81 in the server firewall. Refer to the FAQ for Windows, Linux and macOS for more information.

  • Check if your website is being served properly by Varnish (TM) on port 81 by adding :81 to the domain name in your browser.

  • If Varnish (TM) is working correctly, switch the Apache and Varnish (TM) ports and activate Varnish (TM) on port 80.

  • Remove the firewall rule for port 81.

Varnish is a registered trademark of Varnish Software AB and its affiliates.

Last modification September 7, 2021