Solved: AH00072: make_sock: could not bind to address

Where necessary, you may need to have access to a VPS server so you can follow how to implement the steps in this article.  You can get a cheaper VPS Server from Contabo with 4vCPU cores, 8GM RAM, and 32TB Bandwidth for less than $5.50 per month. Get this deal here now

Table of Contents

Cloud VPS S

$5.50 Monthly
  • 4 vCPU Cores | 8GB RAM


$15.50 Monthly
  • 6 vCPU Cores | 16GB RAM


$17.50 Monthly
  • 8 vCPU Cores | 24GB RAM

The AH00072: make_sock: could not bind to address error occurs when Apache is unable to bind to the port that it is configured to use. By default, Apache is configured to listen to port 80. But if there is an intrusive service occupying this port, or if your firewall system is configured to block this port, Apache won’t be able to listen to the incoming requests from the internet.

To identify and troubleshoot the cause of this error, we can use the following steps:

STEP #1: Investigte with the systemctl status command

We can use the systemctl status command to help us further investigate the problem. On Debian systems like Ubuntu, you can run the following command on the terminal:

sudo systemctl status apache2.service -l --no-pager

If you’re using CentOS and Fedora systems, here is the alternative command you’re meant to run:

sudo systemctl status httpd.service -l --no-pager

The above command is used to retrieve detailed status information about the Apache HTTP Server (apache2) systemd service on a Linux system. The systemctl status command provides an overview of the service’s current state, including its active or inactive status, main process ID (PID), and recent log entries.

The -l flag ensures that the command includes additional details from the service’s logs, providing more comprehensive information. Additionally, the --no-pager flag ensures that the output is not piped to a pager like “less,” allowing the full status information to be displayed directly in the terminal. This command is particularly useful for troubleshooting and monitoring the health of the Apache web server.

Now, the output of the above command will be as shown below:

● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2020-07-28 13:58:40 UTC; 8s ago
     Docs: man:httpd.service(8)
  Process: 69 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 69 (code=exited, status=1/FAILURE)
   Status: "Reading configuration..."
     Tasks: 213 (limit: 205060)
   Memory: 25.9M
   CGroup: /system.slice/containerd.service/system.slice/httpd.service

Jul 28 13:58:40 e3633cbfc65e systemd[1]: Starting The Apache HTTP Server…
Jul 28 13:58:40 e3633cbfc65e httpd[69]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
Jul 28 13:58:40 e3633cbfc65e httpd[69]: (98)Address already in use: AH00072: make_sock: could not bind to address
Jul 28 13:58:40 e3633cbfc65e httpd[69]: no listening sockets available, shutting down
Jul 28 13:58:40 e3633cbfc65e httpd[69]: AH00015: Unable to open logs
Jul 28 13:58:40 e3633cbfc65e systemd[1]: httpd.service: Main process exited, code=exited, status=1/FAILURE
Jul 28 13:58:40 e3633cbfc65e systemd[1]: httpd.service: Failed with result 'exit-code'.
Jul 28 13:58:40 e3633cbfc65e systemd[1]: Failed to start The Apache HTTP Server.

In the above output file, you will notice that these error lines are present:

Address already in use: AH00072: make_sock: could not bind to address

These errors mean that the Apache port is already in use by another process or application:

STEP #3: Understand which service is running on this port

We need to identify the service running on the port on which Apache is supposed to be using. We can achieve this using the ss command:

sudo ss -tulpn | grep :80 | awk '{print $7}'

The above command will list a service running on port 80. This will help you to understand whether to kill it or leave it based on its degree of necessity on your server

RECOMMENDED READING: How to list Linux Processes using the Terminal

STEP #4: Kill the Service or use an alternative port?

At this point, when you discover the intrusive service taking up Apache port 80, you need to decide whether to kill the process bound to it or assign Apache server with a different port.

Killing the Service

If you want to kill the service bound to the port to create room for Apache, then you can use the kill command.

kill [options] <PID>

Alternatively, you can use the pkill command, allowing you to stop the running process by its name:

pkill process_name

RECOMMENDED READING: How to kill processes in Linux Systems using the terminal

Assign Apache with a different port

One of the best things about Apache Server is that it allows you to assign a custom listening port in its configuration file.

Open the Apache configuration file using a text editor. Use the appropriate command based on your system.

For Debian systems like Ubuntu, you can run the following command:

sudo nano /etc/apache2/apache2.conf  

If you’re using CentOS or RHEL, the following command will open the Apache configuration file:

sudo nano /etc/httpd/httpd.conf  # For CentOS/RHEL

You will need to locate the line that starts with Listen followed by the default port (usually 80). Change the port number to your desired port. For example, to use port 8080:

Listen 8080

RECOMMENDED READING: How to install Apache Server on Ubuntu Linux

If you set a different port for Apache, it means that you will need to open it through the firewall: In our example, we’re using 8080 as the custom Apache port:

sudo ufw 8080

STEP #5: Restart the Apache server

Sometimes, restarting the Apache server can resolve minor network or connection-related errors. To restart the Apache server, you can use the following command:

sudo service apache2 restart

STEP #6: Check the firewall settings

Putting aside an intrusive service occupying up the default Apache port, the firewall may be blocking Apache from accepting incoming connections. To check the firewall settings, you can use the following command:

sudo ufw status

If the firewall is blocking Apache, you can open the necessary ports by running the following command:

sudo ufw allow http
sudo ufw allow https

Hire us to handle what you want

Hire us through our Fiverr Profile and leave all the complicated & technical stuff to us. Here are some of the things we can do for you:

  • Website migration, troubleshooting, and maintenance.
  • Server & application deployment, scaling, troubleshooting, and maintenance
  • Deployment of Kubernetes, Docker, Cloudron, Ant Media, Apache, Nginx,  OpenVPN, cPanel, WHMCS, WordPress, and more
  • Everything you need on AWS, IBM Cloud, GCP, Azure, Oracle Cloud, Alibaba Cloud, Linode, Contabo, DigitalOcean, Ionos, Vultr, GoDaddy, HostGator, Namecheap, DreamHost, and more.

We will design, configure, deploy, or troubleshoot anything you want. Starting from $10, we will get your job done in the shortest time possible. Your payment is safe with Fiverr as we will only be paid once your project is completed.