Well, I'm trying to access a python server (for django development) in a Virtual Box VM via vagrant, but I can't connect with it in my windows browsers. I'll try to describe all the things I've done to make this work, so maybe it can help you guys.
My configurations:
I set my vagrant file to allow connections in port 8000 (guest and host)
I have disabled my windows firewall.
I have turned off the firewall on the VM
I have disabled all chrome extensions (including addblock)
I have disabled almost all apps in my windows to minimize the chances that some program could use port 8000
I have unchecked "automatically detect settings" and "use a proxy server for your lan" in the lan settings (windows internet options), then done the ip /release, ip /renew and rebooted my machine
Yes, the python server is running well on the vm
I tried the default 127.0.0.1:8000 (no success) and changed to 0.0.0.0:8000 using the command "python manage.py runserver 0.0.0.0:8000", but still ... :(
I have a nginx server in the vm running well for my php apps in port 80, and i cant access them with no problems
I use pycharm for python development and it starts my server normally in the vm either using 127.0.0.1:8000 or 0.0.0.0:8000
I think that's it, but the error persists, I can't access my python server in my ip 192.168.56.101 in port 8000, this ip is my private network on the vm that runs good with nginx.
But the result is always the same
Whenever I try access http://192.168.56.101:8000/ all my browsers (IE, Firefox, Chrome) cannot complete the request, in Chrome the error is ERR_CONNECTION_TIMED_OUT
Thanks in advance for any help !
My problem was the firewall rules. I dont really need it since its a development environment, so I delete all the rules in /etc/iptables/rules.v4 and save the file. That solve it all. Tks.
Related
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 have a remote development Linux machine (with own IP address) in a VPS provider. I also have my machine that connects to internet via a router. I want a Django process in the server to connect to a pydev debug server on my machine.
I use pydev debugger, this configuration tells django at any host to connect to the given host/port where the debugger is running.
pydevd.settrace('localhost', port=5678, suspend=False)
How to connect to the VPS from my desktop? NAT is impossible since the router and DHCP is not in my control. VPN seems feasible but complicated.
I think the best way to resolve it in this case would be doing a port forwarding through ssh -- I don't have any specific instructions for that, but google has plenty ;)
I have two computers in the same enterprise network. The one with Windows XP (IP 192.168.101.96) and the other with Windows 7 (IP 192.168.101.98).
If I start Django project on PC with Windows XP (python manage.py runserver 192.168.101.96:8001), I can easily access it from Windows 7 PC with browser.
But the opposite way doesn't work. If I start Django project on PC with Windows 7, I can't access it from Windows XP PC.
The same situation is with command python -m SimpleHTTPServer 8001.
I tried to add a rule for external connections on TCP port 8001 in Windows firewall settings. Also I tried to add python.exe to firewall exceptions, but nothing seems to work...
It should be noted that when I start Django server and execute NETSTAT -p tcp -ano command, I can see line:
TCP 192.168.101.98:8001 0.0.0.0:0 LISTENING 6920
But nevertheless, nothing work. What can be the source of the problem?
for access to another computer server , server must be run on port 80.
you must run django server on port 80
python manage.py runserver 0.0.0.0:80
then access with type ip in the browser without post number :
http://192.168.101.98/
good luck
The problem was in ESET Endpoint Security special firewall. It's "automatic mode" blocks traffic without any promt to user. The problem can be solved by adding special rule to this firewall or changing it's main policy to "interactive mode" for example.
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.
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