cookiecutter-django icon indicating copy to clipboard operation
cookiecutter-django copied to clipboard

0.0.0.0:8000 This site can’t be reached

Open tildebox opened this issue 2 years ago • 3 comments

What happened?

When I start PyCharm with the "runserver" configuration and call http://0.0.0.0:8000/ with Google Chrome, I get the message "This site can't be reached".

What should've happened instead?

The website should load.

Additional details

  • OS name and version: Windows 10
  • Python version: 3.10.4

tildebox avatar Jun 06 '22 17:06 tildebox

I think 0.0.0.0 just means to expose the port for other devices. FOr instance, if you try to connect with your phone to your local/private ip address like http://192.168.0.2:8000, then it works. Same with http://localhost:8000. That'll work too. 0.0.0.0 isn't an IP address I believe

Andrew-Chen-Wang avatar Jun 06 '22 18:06 Andrew-Chen-Wang

Then shouldn't cookiecutter-django default to 127.0.0.1?

tildebox avatar Jun 10 '22 12:06 tildebox

Wdym default to?

Andrew-Chen-Wang avatar Jun 10 '22 15:06 Andrew-Chen-Wang

the mention address should be run in your local system like this in pycharm editor

165015167-bd9883f9-3d8e-4372-aa56-bf1b9590c8ad

ADITYADAS1999 avatar Sep 23 '22 04:09 ADITYADAS1999

It works fine on my machine (macOS) with Docker (which I thought was the problem). Is 0.0.0.0 a special IP address that is working differently on Windows? What options have you selected when generating the project? This is in the issue template but I don't see it in the original report... 😞

* Options selected and/or [replay file](https://cookiecutter.readthedocs.io/en/latest/advanced/replay.html):
  On Linux and MacOS: `cat ${HOME}/.cookiecutter_replay/cookiecutter-django.json`
  (Please, take care to remove sensitive information)
    ```json
    # Insert here the replay file content
    ```

(Yes, the questions we're asking in the issue template are actually useful, please fill them...)

browniebroke avatar Sep 24 '22 13:09 browniebroke

{ "cookiecutter": { "project_name": "www.flashlightapp.com Flashlight App for Android", "project_slug": "flashlightapp", "description": "Flashlight App", "author_name": "Flashlight", "domain_name": "flashlightapp.com", "email": "-", "version": "2.1.0", "open_source_license": "Not open source", "timezone": "UTC", "windows": "y", "use_pycharm": "y", "use_docker": "n", "postgresql_version": "14", "cloud_provider": "None", "mail_service": "Other SMTP", "use_async": "n", "use_drf": "n", "frontend_pipeline": "None", "use_celery": "n", "use_mailhog": "n", "use_sentry": "n", "use_whitenoise": "y", "use_heroku": "n", "ci_tool": "None", "keep_local_envs_in_vcs": "n", "debug": "y", "_template": "https://github.com/cookiecutter/cookiecutter-django", "_output_dir": "C:\Users\flashlightapp\Downloads\cookiecutter-django-test\1" } }

tildebox avatar Sep 24 '22 23:09 tildebox

In my opinion, it is not a bug at all.

When you run your application on host 0.0.0.0:8000, the application is bound to all network interfaces on the machine it is running on. This allows the application to be accessible from any device connected to the same network as the machine running the application.

However, when you try to access the application using the address 0.0.0.0:8000 in your browser, the browser may not be able to resolve the IP address correctly. This is because 0.0.0.0 is a special IP address representing all network interfaces on the local machine, but it is not a valid IP address for external connections.

On the other hand, when you use the address 127.0.0.1:8000, you are accessing the application through the loopback interface, a virtual network interface that allows a client to connect to a server running on the same machine. This address is always available and accessible from the same machine the application runs on, regardless of the network configuration.

To access your application from another device on the same network, you should use the IP address of the machine running the application instead of 0.0.0.0:8000.

To make a long story short - it is not a bug, it is how networking works, and you should use 127.0.0.1:8000 when you run your application on localhost.

mostaszewski avatar May 10 '23 18:05 mostaszewski