简体   繁体   中英

How do I access my Django server from outside?

My computer is connected to our college's local network. I am able to access my django server in the same network from another computer. When I try to do the same from an outside internet connection, I get an " Webpage not found error" . I used the ip given by Whatsmyip.com to access it from outside. Also, I started the server using the command : python manage.py runserver 0:8000

Use something like:

These create a tunnel to your localhost. You cannot host from a common IP shared by an internal network. Read more about localhost here: http://en.wikipedia.org/wiki/Localhost

Please note that the tools above allow you to share a link to your site and is mostly meant for development and testing. If you really want to host a Django server, either do it on an external server or contact your infrastructure team in college to see if they even allow such a thing.

For external hosting, Heroku ( https://www.heroku.com ) can be a good option with a reasonable free plan.

This depends on your college network. Often, computers in local networkds are behind a NAT (one single external ip for several clients). At this point, the request cannot be routed from out- to inside. Maybe a college technician can help you to route your page.

I think it's first important to note that manage.py runserver is for local development. It is not meant to be used for deployment.

If you want to access your website from "outside", you should consider deploying it . You can then read more about this here : https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/

Also, like stated in other answers, depending on how is configured your college network, it may not be possible to access your development server from outside, because :

  • It probably has NAT rules for local networks
  • There are probably port restrictions and a firewall for outside access (usually college networks are very restrictive from inside AND from outside)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM