I have a Django development server running on a remote centos VM on another lan. I have set up port forwarding using Secure CRT to access the web page through my browser from my desk pc. I am currently not using apache with the development server and is shutdown.
I start the server by running python manage.py runserver 0.0.0.0:80.
When I type either the ip or www.localhost.com into the web browser, my URL is read as if it has been doubled with the host being read as if it was also the path.
Page not found (404)##
Request Method: GET
Request URL: http://www.localhost.com/http://www.localhost.com/
When I try to access the development server from within the same LAN the page loads up fine.
I have been searching through the django documentation and stack overflow, but I have yet to find a similar problem to this. Does anyone have any thoughts on why this may be happening and what could be a possible solution?
Thank you very much in advance!
It looks like the request URL is incorrect:
http://www.localhost.com/http://www.localhost.com/ should probably be http://actual_machine_IP.com/
I'd start searching there. You won't be able to access the VM's port 80 from a different lan using localhost as the hostname since localhost is probably already set in your hosts file.
If you want to test your dev environ remotely, can I suggest either setting up Apache properly with port 80 (as opposed to using django's dev server--privilege restrictions and all that can be circumvented with sudo and other bad practice) or use a pre-built shared dev service like vagrant share.
Related
I've been working on a website for the past month, and now its time for me to host the django website onto a private server. Is there a detailed method on how I'm supposed to host the website onto a specific IP address assigned to my system?
This is my first time dealing with hosting a server and i dont know much about it.
Also, once i host it, How do i change the link from being the IP address to an actual link like "12345678.com" or something like that?
(The website should be hosted in such a way that only the people who are in the same network/lan connection should have access to the website.)
I have wamp on the system and the system has a Windows Server OS (if this info helps)
you can run your codes with manage command like this
python manage.py runserver 0.0.0.0:8000
but its strongly recommended to run your code with a web server like nginx or apache read this tutorial to run your site on a linux server
https://www.digitalocean.com/community/tutorials/how-to-set-up-uwsgi-and-nginx-to-serve-python-apps-on-ubuntu-14-04
on windows you can use IIS but its not recommended. its performance is not good
to use 1234567890.com instead of using server ip address you must setup a DNS server on your local network. in linux you can use bind and windows server have its own DNS server. but in your DHCP configuration you must set this DNS server as clients DNS.
I'm trying to connect to my website from another node on another network. If the nodes are in the same network, i can connect to the website without a problem.
I've forwarded port for ssh and Django (8000), I also have apache ready on port 9080.
ssh and apache ports work fine when connecting to them from external ip address, Django does not for some reason.
First, i tried to run the server on port 8000:
python manage.py runserver 0.0.0.0:8000
This works completely fine when connecting from the node that is in the same network as the server, but for some reason, whenever i try to access it from external ip address, the connection is refused.
To make sure it was Django, I also tried running the server on the same port as Apache (9080), although, i didn't expect "errorless" response, since i knew that port was occupied. But there was no change at all, I was still getting the same Apache page that i would get before.
I also tried allowing port 8000 on firewall:
sudo ufw allow 8000/tcp
But pretty sure this is not the problem, since this Debian came without any firewall.
I also tried to empty ALLOWED_HOSTS in settings, but there was no progression.
It seems like Django has no effect for external connections, what could be the reason?
I also struggle to understand the purpose of other http web server platforms in this case (e.g Apache, Nginx), Isn't Django creating a webserver itself along with its custom wsgi?
Firewall is not the problem, neither is the web server, then may the problem be caused by the Django itself? Maybe it is outer firewall?
It is not clear how you are configuring Apache to forward requests to Django, it seems like you are treating those as two independent components. If you want to use a web server in front of Django (recommended for production envs), you need to configure both Apache and Django.
Then, as you are running django in dev mode (python manage.py runserver 0.0.0.0:8000), you should reach Django in http://server_ip:8000 regardless of Apache, perhaps there is another firewall blocking the connection. Use tracert / traceroute to find out where the connection is blocked.
FInally, for production environments, it is recommended to use a web server in front of Django to increase security and performance. See the docs for further information.
My guess is that you have another firewall blocking the port. You opened the local firewall using ufw, but there may be an outer firewall.
python manage.py runserver 0.0.0.0:8000 starts correctly? If so, keep an eye in the log.
Inside the server, do a request wget http://localhost:8000. The request should be logged
If you can reach Apache in port 9080 from outside the server, you can:
Use nmap to find the opened / closed / filtered ports in the server to find if there is another firewall inbetween.
Configure Apache to forward requests to Django, although this does not solve the problem
In your question you say that you have forwarded port for ssh and Django. What exactly is this? Are you sure that you have not misconfigured your ssh server to listen in port 8000?
I want to make the development server in Django be on the internet while running Windows 10. How can I do this?
By the way, when I try to use my external IP, it doesn't work. It says that I can't use it
While starting the Django Server, mention the IP and PORT from which you want to accept the requests. Mention 0.0.0.0 to open it for all as:
python manage.py runserver 0.0.0.0:80
By default the Django's server accepts requests only via localhost.
Now make a request via using public IP of the system on which your Django's server is running
You can try a deployment on Heroku. Is relativelly easy to set up and provides you with a live server in minutes.
Sorry about the confusion, this is an old question but what actually happened was that I didn't add any port forwarding rules on my router. If I did, then the solutions raised by others would've worked. Since I didn't port forward, I just ended up hosting it on heroku.
I can't seem to figure this out. I created a new Ubuntu VM on Azure and I can SSH into it. I installed Node (which I've done many times) and I tried to run the test app from nodejs.org:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
However, when I go to the IP (which is the same one I SSHed into the box from) + :1337 it just never loads. I tried :80 too, but still no luck. I also tried running python -m SimpleHTTPServer on :8000 and I still can't view the site. I must be missing something.
Just so you know, I'm just trying to setup a simple dev box with a bunch of projects on it. I want to be able to work on my projects anywhere. Some are 100% front-end JS projects so SimpleHTTPServer would be fine. Some are Node projects too. In either case, I just want to be able to hit some port and see what I'm working on.
Oh also I opened up the Azure firewall to the VM, redirecting traffic from port 80 to port 1337 (https://www.evernote.com/shard/s5/sh/3aef8e76-04f6-48cb-84f9-32462bc425a7/f0cd749773a9d09cee66d00fe3e707c0)
You are listening loopback ip address. Try .listen(1337, '0.0.0.0'); to listen on all network interfaces
urgh azure. i cannot get port 80 open. is it the machine iptables?? some azure magical thing.
i know it cant be that hard.
unlike your view i do not see 'NONE' for load balancer. i see '--'/ whatever that means.
I've been tasked by my programming teacher to learn Django. However, I need to code on a command line linux box and therefore cannot access the web page from said linux box.
To test, I need to host it on the local IP of the computer rather than localhost. I’m currently running the Django development server using this command:
python manage.py runserver 0.0.0.0:8000
Firefox and Chrome can access the development server at the Linux box’s IP address, but Internet Explorer can’t.
Unfortunately (I am said teacher), I can't provide a linux host - only a linux server and a windows host to do development on.
He's actually running the web server correctly, with the command provided by Paul. But for some reason, it's only visible in Firefox/Chrome, IE just provides a generic "Webpage cannot be displayed"
But this problem can be solved by using the entire address: http:// isn't optional like it is in Chrome and Firefox.
When you run the development server, you can make it available on the local network by specifying the IP address 0.0.0.0 for it, like this:
python manage.py runserver 0.0.0.0:8000
If your Linux box’s local IP address is e.g. 192.168.1.37, you’d access the development server at:
http://192.168.1.37:8000
Setup nginx to listen on a public port and proxy all of the requests to the django runserver.
You need to specify the IP clearly in the command line like this in order to let other clients to access. You also have to enable the port 8000 in the firewall:
python manage.py runserver 192.168.1.37:8000