Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Django Debug Toolbar Visibility and INTERNAL_IPS in Docker Environments #4976

Closed
wants to merge 3 commits into from

Conversation

DavidPacioianu
Copy link
Contributor

@DavidPacioianu DavidPacioianu commented Apr 8, 2024

Problem: The Django Debug Toolbar does not display in Docker (tested on MacOS) because socket.gethostname() returns Docker's default IP (172.21.0.1), not the host's IP.

Solution: Switch socket.gethostname() to host.docker.internal to accurately reference the host machine's IP from within Docker containers. This change ensures the the host's IP is added to INTERNAL_IPS and the Django debug toolbar is visible when developing in Docker.

DavidPacioianu and others added 3 commits April 8, 2024 14:28
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`.
@foarsitter
Copy link
Collaborator

This might be working on MacOS, but doesn't work on linux:

Python 3.11.7 (main, Feb  1 2024, 05:12:23) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.gethostbyname_ex("host.docker.internal")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
socket.gaierror: [Errno -2] Name or service not known

@foarsitter foarsitter added the waiting Waiting for an answer and auto-close after 10 days label Aug 27, 2024
Copy link
Contributor

github-actions bot commented Sep 7, 2024

Automatically closing after waiting for additional info. To re-open, please provide the additional information requested.

@github-actions github-actions bot closed this Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting Waiting for an answer and auto-close after 10 days
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants