Help with changing apache port from 80 to 8080 via cPanel


Dec 10, 2013
cPanel Access Level
Root Administrator

Have used the 'Tweak settings' to change the apache port from 80 to 8080 in preparation for installing Varnish. I then restarted Apache.

However, i can only access domains in the format and get a connection refused when trying to access

Is there another setting i need to change somewhere?



Well-Known Member
Feb 25, 2010
Houston, TX
cPanel Access Level
Root Administrator
It is doing exactly what you told it to do. :)

You set Apache to listen on port 8080 instead of 80. Port 80 is the default port for HTTP. When you do not specify a port, your browser connects to port 80, and since nothing is listening on port 80 on your server anymore (because you changed the Apache port), the connection is refused.

This is normal behavior when you change the Apache port. Presumably you want varnish to listen on port 80 and act as a proxy to Apache on port 8080. Until you install varnish, you will need to specify port 8080 to access your sites. Web browsers do not usually automatically try port 8080 when a connection is refused on port 80.

You may want to change the Apache port back to 80 until just before you are ready to install and deploy varnish. We do not provide support for varnish. Other users in this forum may be able to help you, and the varnish documentation may also be helpful.


Active Member
Jul 19, 2006
Follow the below steps to configure the Varnish.

(a) This is how to setup Varnish. You have to follow few steps to configure Varnish so your server will be faster than before it your visitors will feel how fast it loads. What are you goint todo? All you have to do is making Varnish to run on port 80 while Apache on port 8080. First configuration file you need to edit is located at “/etc/default/varnish”. use Vi to edit it.

vi /etc/default/varnish

Now look for these lines there under “Alternative 2″:

DAEMON_OPTS="-a :6081 \
-T localhost:6082 \
-f /etc/varnish/default.vcl \
-S /etc/varnish/secret \
-s malloc,256m"

Now edit those lines to match following to make it works in port 80:

DAEMON_OPTS="-a :80 \
-T localhost:6082 \
-f /etc/varnish/default.vcl \
-S /etc/varnish/secret \
-s malloc,256m"

Once done save it and exit.

(b) As you will use Varnish Configuration Alternative 2 (with VCL), so you have to also the default.vcl file which tells varnish where to look for the webserver content (in this case is to fetch from Apache in port 8080). This step is also called as to set the backend server. Use Vi again to edit it.

vi /etc/varnish/default.vcl

Now you’ll see some lines like below. If not, edit it to match as following:

backend default {
.host = "";
.port = "8080";

The config above says that Apache as the backend server is available on localhost at port 8080 and Varnish will run in front of it listening on port 80 that previously used by Apache.

Now you’ve setup Varnish configuration to work on port 80. Next step, you have to also make Apache to work on port 8080. Without doing this step, Apache will still running on port 80 and so Varnish. Now edit Apache port setting and set it listen to port 8080 instead of 80

find “NameVirtualHost” and “Listen” lines and replace 80 with 8080.



edit it to:


(c) Now edit the virtual hosts file for your site’s domain name (in case if you host more than one website in your server). I assume you knew about virtualhost file and how to set it. So edit the conf file and search for VirtualHost and set the port no as 8080, Like below.

<VirtualHost *:8080>

(d) Restarte the apache and varnish service, Like below.

service apache2 restart
service varnish restart

That's It!

Please let me know If you have any doubt.