Skip to content
Sign upLog in
← Back to Community

Imported a django web app from github, and the server runs but can't connect in browser window

Profile icon
geekandglitterHacker

I'm new to repl.it. I'm running on Windows 10. Here's what I did:

Step One: I imported my Django web app from Github

Step Two: Configured .replit to include:
language = "python3" and
run = "python manage.py runserver"

Step Three: Clicked on the RUN button, with a good outcome: ("starting development server at http://127.0.0.1:8000/")

Step Four: Looked at browser window to see http://127.0.0.1:8000/ but there's a message that it refuses to connect.

I've tried turning off my windows firewall, I've tried three different browsers, I've tried updating ALLOWED_HOSTS in settings.py, and I've tried port 8080 and 3000. Still no joy.

What am I missing? It could be something simple. Thank you.

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
Profile icon
geekandglitter
Comments
hotnewtop
Profile icon
Coder100

Change your .replit to:

language = "python3" run = "python manage.py runserver 0.0.0.0:8000"
Profile icon
geekandglitter

@Coder100
When I switch to 0.0.0.0:8000, I get a Bad Request message: DisallowedHost at /
Invalid HTTP_HOST header: '1944af39-b599-40cf-a6ba-c1a9f3897dcc.id.replitusercontent.com'. You may need to add '1944af39-b599-40cf-a6ba-c1a9f3897dcc.id.replitusercontent.com' to ALLOWED_HOSTS.

Can you advise me?

Profile icon
Coder100

add it to the allowed_hosts

@geekandglitter

Profile icon
Coder100

https://docs.djangoproject.com/en/1.11/ref/settings/#allowed-hosts

@geekandglitter

Profile icon
Coder100

simply make the allowed hosts *

@geekandglitter

Profile icon
geekandglitter

@Coder100
Okay I have added *
@geekandglitter
to allowed hosts. Now I'm getting this message from my browser: This site can’t be reachedThe webpage at http://0.0.0.0:8000/ might be temporarily down or it may have moved permanently to a new web address.
ERR_ADDRESS_INVALID

Profile icon
Coder100

@geekandglitter

image

i see this

Profile icon
Coder100

you should be visiting https://thecattycook.geekandglitter.repl.co/ not your local machine.


@geekandglitter

Profile icon
Coder100

Make sure the host is 0.0.0.0:8000 not 127.0.0.1:8000 or else it will not work.

Profile icon
geekandglitter

@Coder100
It is. Here is my .replit:
language = "python3"
run = "python manage.py runserver 0.0.0.0:8000"

Profile icon
geekandglitter

@Coder100
I've done everything exactly as you told me. There must be one more thing I'm missing. I'll take any suggestions you've got.

Profile icon
Coder100

@geekandglitter

image

oh hey look it works!

Profile icon
geekandglitter

@Coder100
You did it! You solved it! When I went to the right place (duh I should have known) it told me what to add to ALLOWED_HOSTS. Once I did that, it worked. Here's what it said to add to ALLOWED_HOSTS:
thecattycook.geekandglitter.repl.co

@Coder100
You rock!

Profile icon
Coder100

yay!! No problem :D
Mark as correct answer?

@geekandglitter