Search code examples
phpapachedockerlumenamazon-ecs

Docker Apache with PHP - Address not available: AH00056: connect to listener on [::]:80


I have a project built in Lumen (php Framework) hosted on a docker container built from alpine as base image using apache2 server with php 7.x

Here's part of my Dockerfile:

FROM alpine:3.8
MAINTAINER Latheesan Kanesamoorthy

RUN apk add \
        --no-cache \
        --update \
        apache2 \
        composer \
        nano \
        bash \
        curl \
        php7 \
        php7-apache2 \
        php7-curl \
        php7-dom \
        php7-mbstring \
        php7-pdo_mysql \
        php7-session \
        php7-sockets \
        php7-tokenizer \
        php7-xml \
        php7-xmlwriter \
    && mkdir -p /run/apache2 \
    && ln -sf /dev/stdout /var/log/apache2/access.log \
    && ln -sf /dev/stderr /var/log/apache2/error.log

The purpose of this project is to receive http post requests (i.e. webhook events from external system) and process them.

When the project is deployed, it runs fine for several days before this error starts showing up in our datadog logs:

[core:warn] [pid 9] (99)Address not available: AH00056: connect to listener on [::]:80

When this error occurs, the site/project is not publicly accessible but the apache is still running. If i restart the container, everything goes back to normal.

Upon investigating this further, I noticed this happens every time my api is hit simultaneously. I.e. 3 days ago, project was hit with 145 request simultaneously and since then the app is no longer accessible.

Apache is refusing to serve any new request but the container is up and running and there's plenty of memory/disk-space available to the container.

Any idea what causes this? do I need to optimise the mpm.conf to allow for more workers / child processes etc.? I am currently using stock config.


Solution

  • The reason for this error is because apache is listening to port 80 on IPv4 & IPv6. This will explicitly tell apache to listen to IPv4.

    In apache config change:

    Listen 80

    to

    Listen 0.0.0.0:80

    Make sure the file is being copied in to your docker container and being used in apache.

    Or add an extra step in the Dockerfile:

    && sed -i 's/^Listen 80$/Listen 0.0.0.0:80/' /etc/apache2/httpd.conf