Django Debug Toolbar + Docker: The Missing INTERNAL_IPS Problem

작성자

카테고리:

← 피드로
DEV Community · Merdas369 · 2026-06-13 개발(SW)

Merdas369

Django Debug Toolbar Didn’t Appear When Running Django in Docker

I’m currently working on an online accessories shop as a personal project. I usually use Django Debug Toolbar in all of my Django projects, so setting it up is almost automatic for me.

This time, however, my project was running inside Docker.

After preparing everything and starting the containers, I opened the browser and noticed that the Django Debug Toolbar panel wasn’t showing up.

My first thought was that I had missed a setup step, so I went back to the Django Debug Toolbar documentation and checked everything again. I followed the installation guide step by step and verified all the settings. Everything looked correct, but the toolbar still didn’t appear.

After searching online for a while, I found the real cause.

Django Debug Toolbar only appears when the request comes from an IP address listed in “INTERNAL_IPS”. Normally, when running Django locally, “127.0.0.1” or “localhost” is enough.

With Docker, things are a little different. The request doesn’t always come from the usual local address, so Debug Toolbar may think the request is coming from an external IP and refuse to display itself.

To discover the actual IP address reaching Django, I created a simple view:

from django.http import HttpResponse

def test(request):
    return HttpResponse(request.META.get("REMOTE_ADDR"))

Enter fullscreen mode Exit fullscreen mode

When I visited that endpoint, the response was:

172.18.0.1

After adding that IP address to “INTERNAL_IPS”:

INTERNAL_IPS = [
    "127.0.0.1",
    "172.18.0.1",
]

Enter fullscreen mode Exit fullscreen mode

the Django Debug Toolbar appeared perfectly in the browser.

What I Learned

This issue reminded me of an important debugging lesson:

When something that normally works suddenly stops working after introducing a new tool or layer (such as Docker), don’t assume the original tool is broken. Sometimes the new component changes the environment in a way that affects the existing behavior.

In my case, Django Debug Toolbar was working exactly as designed. Docker simply changed where the request was coming from.

원문에서 계속 ↗

코멘트

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다