×


FreeBSD Apache Jail Connection refused connect to listener failed

Are you facing the error 'FreeBSD Apache Jail: Connection refused'?

This guide is for you.


In the process of 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 Ibmi Media, as part of our Server Management Services, we regularly help our Customers to fix FreeBSD related errors.

In this context, we shall look into how to fix the 'FreeBSD Apache Jail: Connection refused' issue for our customers.


Steps to fix the error '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 ip_address:80

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.

Listen 100.X.X.120:80

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 Linux issue? – We are available 24*7. ]


Conclusion

This article covers how to fix 'FreeBSD Apache Jail: Connection refused' issue for our customers. 

While running Apache 2 server under FreeBSD jail, you may see a warning error messages in /var/log/httpd-error.log as follows:

[warn] (61)Connection refused: connect to listener on 0.0.0.0:80


To resolve this FreeBSD Apache Jail error:

1. You need to always set your actual, real IP. Open httpd.conf

# vi /usr/local/etc/apache22/httpd.conf

2. Find out Listen directive:

#Listen 12.34.56.78:80

Listen directive allows you to bind Apache to specific IP addresses and/or ports, instead of the default. 

Change this to Listen on specific IP addresses as shown below to prevent Apache from glomming onto all bound IP addresses i.e. 0.0.0.0 which is not available in jail

3. Save and close the file. Restart apache:

# /usr/local/etc/rc.d/apache22 restart