Can't change virtualhost listen port without crashing my site

  • Posted July 21, 2014

Hi, I am trying to configure Varnish in an Ubuntu 14.04 server running three virtual hosts and I am getting stuck in the previous step of changing listen port in apache ports.conf and sites-available/site.conf.

It doesn’t matter what port I try (recommended 8080, 8585, 4000, etc), after restarting the server I get a connection error when trying to visit my website.

Can you help me?


What’s the connection error you’re getting? Are there any error messages in /var/log/apache2/error.log?

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

This was solved after configuring varnish. Thanks.

Update: returns the site. returns a 301 redirection to, which returns fetching error since tries to connect on port 80.

Thanks, I didn’t knew that. After changing ports to 8080 (8585 was not allowed) in in apache ports.conf and sites-available/site.conf I´m experiencing a strange behaviour: returns a server error returns

Why is that?

Your browser always uses port 80 unless you tell it otherwise, as in

Varnish listens on port 80 and makes requests to your web server on the port you specify, such as 8585. Once you change the port in ports.conf, you should be able to browse your site using the port you specify (if it is open on your firewall). Once Varnish is in place and configured, you will be able to browse your site as usual without specifying a port number - Varnish will be completely transparent to you. (Pretty slick how they named that.)

I´m sorry, I missed some answers:

What’s the connection error you’re getting? Connect to 188.226.XXX.XXX on port 80 … failed Error 111: Connection refused Error while fetching URL

Not sure why it using port 80 since I have set the listen port to 8585 in ports.conf

Does Varnish output any errors? Varnish is installed but not yet configured. I was just messing around with the apache listen port when I noticed the error. And yes, Varnish seems to be logging another error: varnishd[5535]: -T localhost:6082 Could not be resolved

are u sure you enabled your vhost then? Yes, I am able to browse my site if i set the ports.config and virtalhost listen port back to 80. The problem is that I need to change it in order to activate Varnish. Am I wrong?

are u sure you enabled your vhost then?

Nothing there… no error is being recorded.

now how about that particular vhost error log?

I don’t see any error. Am I missing something?:

[Mon Jul 21 17:54:58.001140 2014] [:notice] [pid 1607] ModSecurity for Apache/2.7.7 ( configured. [Mon Jul 21 17:54:58.001512 2014] [:notice] [pid 1607] ModSecurity: APR compiled version=“1.5.1-dev”; loaded version=“1.5.1-dev” [Mon Jul 21 17:54:58.001529 2014] [:notice] [pid 1607] ModSecurity: PCRE compiled version="8.31 "; loaded version=“8.31 2012-07-06” [Mon Jul 21 17:54:58.001539 2014] [:notice] [pid 1607] ModSecurity: LUA compiled version=“Lua 5.1” [Mon Jul 21 17:54:58.001555 2014] [:notice] [pid 1607] ModSecurity: LIBXML compiled version=“2.9.1” [Mon Jul 21 17:54:59.010104 2014] [mpm_prefork:notice] [pid 1608] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.3 configured – resuming normal operations [Mon Jul 21 17:54:59.010203 2014] [core:notice] [pid 1608] AH00094: Command line: ‘/usr/sbin/apache2’

By the way, already tried to disable modsecurity and that didn’t help.

try checking apache error log for details