Stuck with ‘FreeBSD Apache Jail: Connection refused’? We can help you.
While using Apache on FreeBSD we may end up with this error at times.
FreeBSD is an operating system for a variety of platforms that focuses on features, speed, and stability.
Here at Bobcares we recently had a customer request to fix a similar issue as a part of our Server Management Services.
Today let’s see how our Expert Support Engineers fix the ‘FreeBSD Apache Jail: Connection refused’ issue for our customers.
Steps to fix ‘FreeBSD Apache Jail: Connection refused’
This error is usually seen as warning error messages in /var/log/httpd-error.log as given below:
[Mon Mar 14 21:47:09 2021] [warn] (61)Connection refused: connect to listener on 0.0.0.0:80 [Mon Mar 14 21:47:10 2021] [warn] (61)Connection refused: connect to listener on 0.0.0.0:80 [Mon Mar 14 21:47:11 2021] [warn] (61)Connection refused: connect to listener on 0.0.0.0:80
We need to fix this to avoid these warning messages from flooding Apache log files.
Before going into the step to fix this we will see the cause.
Cause for ‘FreeBSD Apache Jail: Connection refused’ warning message:
This happens because, under FreeBSD jail, we do not have loopback addresses – 127.0.0.1 and 0.0.0.0.
The following steps can be used to fix this:
Here we will be fixing the issue on Apache 2 server under FreeBSD jail.
Since we do not have a loopback address under FreeBSD jail, we should not configure any server including httpd with 0.0.0.0 or 127.0.0.1 IP address.
To fix this issue we need to set our actual, real IP address.
We can do this by opening httpd.conf in any text editor as given below:
# vi /usr/local/etc/apache22/httpd.conf
And then we need to find out ‘Listen’
Listen directive allows us to bind Apache to specific IP addresses and/or ports, instead of the default.
We must change this to Listen on specific IP addresses that are our real or actual IPs.
This will prevent Apache from glomming onto all bound IP addresses i.e. 0.0.0.0 which is not available in jail.
We can add a real Ip address as given below for httpd.
After adding the IP we can save and exit the file.
Finally, we need to restart apache using the following command:
# /usr/local/etc/rc.d/apache22 restart
[Still facing this issue? – We are available 24*7]
To conclude we saw how our Support Engineers fix ‘FreeBSD Apache Jail: Connection refused’ issue for our customers