From c50ca2bf3f2c91dfed6edaa679bc23227236eecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20P=C4=83cioianu?= Date: Mon, 8 Apr 2024 14:28:36 +0300 Subject: [PATCH] Fix adding host ip to INTERNAL_IPS when using Docker The ip returned by `socket.gethostname()` is default docker `172.21.0.1` ip, which is not the actual IP of the host. Replace `socket.gethostname()` with `host.docker.internal`. --- {{cookiecutter.project_slug}}/config/settings/local.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/local.py b/{{cookiecutter.project_slug}}/config/settings/local.py index f1edb514b..7d538b8fd 100644 --- a/{{cookiecutter.project_slug}}/config/settings/local.py +++ b/{{cookiecutter.project_slug}}/config/settings/local.py @@ -73,7 +73,7 @@ INTERNAL_IPS = ["127.0.0.1", "10.0.2.2"] if env("USE_DOCKER") == "yes": import socket - hostname, _, ips = socket.gethostbyname_ex(socket.gethostname()) + hostname, _, ips = socket.gethostbyname_ex("host.docker.internal") INTERNAL_IPS += [".".join(ip.split(".")[:-1] + ["1"]) for ip in ips] {%- if cookiecutter.frontend_pipeline in ['Gulp', 'Webpack'] %} try: