Invalid HTTP_HOST header: 'containers'

We are regularly seeing this error message in our logs from our Django app:

Invalid HTTP_HOST header: 'containers'. You may need to add 'containers' to ALLOWED_HOSTS.

It is occurring when something is trying to GET /healthcheck from our Django server. Is something in Aptible trying to GET this URL every 10 seconds or so?

This is the expected behavior for Runtime Health Checks which attempt to contact http://containers/healthcheck . Aptible uses the containers hostname rather than the container IP address so that it can be added to ALLOWED_HOSTS (because the container IP is subject to change when the container or underlying hardware restarts).

I would recommend adding containers to your list of ALLOWED_HOSTS to avoid this issue. However this error should not cause a problem with your App’s functionality unless you enable Strict Health Checks, which would interpret a 4xx/5xx HTTP response as an unhealthy container and only accept 200 s.

1 Like