Can't access the Django server at http://127.0.0.1:8000/

↘锁芯ラ 提交于 2019-12-12 18:22:27

问题


At firt time it worked totally fine but it is showing this issue now:

app$ python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
September 03, 2017 - 17:28:43
Django version 1.11.4, using settings 'aggregator.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

It says its running but I can't Access it on that address. What could have been possibly wrong?

my docker-compose file:

    version: "2"

services:
  postgres:
    image: postgres:9.6
    volumes:
      - pgdata:/var/lib/data/postgres

  backend:
    build: .
    command: gosu app bash
    volumes:
      - .:/app
      - pyenv:/python
    links:
      - postgres:postgres
    ports:
      - 8000:8000

volumes:
  pyenv:
  pgdata:

回答1:


for develop you can try

in settings.py:

ALLOWED_HOSTS = ['*']

and then

python manage.py runserver 0.0.0.0:8000



回答2:


To answer your question of

What could have been possibly wrong?

A number of things:

  1. The mapping of your parts is incorrect. Your application is mapping to another port other than 8000. Check which port your application is mapped to. Not by checking the output of python manage.py runserver, because that is not the command you run in your container. Check the logs of your container.
  2. When your command gosu app bash is run, there is an error. Check the output of docker logs backend.
  3. You could be running the docker-compose up -d command incorrectly.

Post the out put of the logs if you want more information.



来源:https://stackoverflow.com/questions/46026116/cant-access-the-django-server-at-http-127-0-0-18000

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!