I run the server in c9 (django workspace). There were no errors and it said
Starting development server at http://127.0.0.1:8000//.
However, when i open this site it says
This site can’t be reached
127.0.0.1 refused to connect.
Can anyone help me fix this issue
127.0.0.1 is your local computer, not the c9 instance. The docs refer to a unique URL for each app, like: http://<workspacename>-<username>.c9users.io:8081
So, try using runserver like this: python manage.py runserver $IP:$PORT
You can then look in your browser tab for the server address that you can see your app running on, which will be similar to the one above. You'll use that when testing instead of localhost or 127.0.0.1.
Check out the Django guide on their site for more details.
In the documentation says that you use a URL they give to you (not localhost) to access the server
Use the Share button on the top to figure out the URLs of running Application and the Preview.
See https://docs.c9.io/docs/run-an-application#section--pre-view-your-application
Related
Not Found: /socketcluster/
[06/Aug/2020 21:45:44] "GET /socketcluster/ HTTP/1.1" 404 3181
this happens every 61 secounds while I am running the django webserver, using "python3 manage.py runserver". I am very new to web development and have no clue what this is or means, any help is appreciated.
P.S. Do I need a db to handle requests for the web server
This is happening for me as well. I'm still looking into the issue and I'll update this when I have a better answer, but I've found a temporary solution.
If you start the local Django server on a different port than the default 8000, the pesky requests go away:
python manage.py runserver 8001
Maybe some other process currently running thinks there's a socketcluster server active on post 8000, or something hidden in my codebase.
I had this problem and it turned out to be a recently installed chrome extension.
I was tasked with making some changes to a Django application. I've never worked with Django and I am having trouble figuring out how to get my changes to compile and be available online.
What I know so far is that the application is currently available online. netstat tells me that httpd is listening on port 80. My change was made in the myapp/views.py file.
I tried to restart httpd using services httpd restart but my changes did not take effect. I've been looking into the issue a bit an I believe that I need to run a command along the lines of:
I tried calling python manage.py runserver MY.IP.AD.DR:8000 and I get:
python manage.py runserver 129.64.101.14:8000
Validating models...
0 errors found
Django version 1.4.1, using settings 'cutsheets.settings'
Development server is running at http://MY.IP.AD.DR:8000/
Quit the server with CONTROL-C.
Nice that no errors are found but when I navigate to http://MY.IP.AD.DR:8000/ I just get a "Unable to connect" message from my browser. I tried with port 81 too and had the same problem.
Without knowing exactly how your application is set up, I can't really say exactly how to solve this problem.
I can tell you that it's quite common to use two web servers with Django - one handles the static content, and reverse proxies everything else to a different port where the Django app is listening. Restarting the normal HTTP daemon therefore wouldn't affect the Django app, so you need to restart the one handling the Django app. Until you restart it, the prior version of the code will be running.
I generally use Nginx as my static server and Gunicorn with the Django app, with Supervisor used to run Gunicorn, and this is a common setup. I recommend you take a look at the config for the main web server to see if it forwards anything to another port. If so, you need to see what server is running on that port and restart it.
Also, is there a Fabric configuration (fabfile.py)? A lot of people use Fabric to automate Django deployments, and if there is one then there may be a command already defined for deploying.
So, I have looked around stack overflow + other sites, but havent been able to solve this problem: hence posting this question!
I have recently started learning django... and am now trying to run it on ec2.
I have an ec2 instance of this format: ec2-xx-xxx-xx-xxx.us-west-2.compute.amazonaws.com on which I have a django app running. I changed the security group of this instance to allow http port 80 connections.
I did try to run it the django app the following ways: python manage.py runserver 0.0.0.0:8000 and python manage.py runserver ec2-xx-xxx-xx-xxx.us-west-2.compute.amazonaws.com:8000 and that doesnt seem to be helping either!
To make sure that there is nothing faulty from django's side, I opened another terminal window and ssh'ed into the instance and did a curl GET request to localhost:8000/admin which went through successfully.
Where am I going wrong? Will appreciate any help!
You are running the app on port 8000, when that port isn't open on the instance (you only opened port 80).
So either close port 80 and open port 8000 from the security group, or run your app on port 80.
Running any application on a port that is less than 1024 requires root privileges; so if you try to do python manage.py runserver 0.0.0.0:80 as a normal user, you'll get an error.
Instead of doing sudo python manage.py runserver 0.0.0.0:80, you have a few options:
Run a pre-configured AMI image for django (like this one from bitnami).
Configure a front end server to listen on port 80, and then proxy requests to your django application. The common stack here is nginx + gunicorn + supervisor, and this blog post explains how to set that up (along with a virtual environment which is always a good habit to get into).
Make sure to include your IPv4 Public IP address in the ALLOWED_HOSTS section in Django project/app/settings.py script...
So for a school project, I have to follow the steps in the "Writing your first Django App" Tutorial on Django's website, but we're supposed to have it on our EC2 instances, which are running Ubuntu 12.04.
In the tutorial, it says:
Now, open a Web browser and go to “/admin/” on your local domain – e.g., http://127.0.0.1:8000/admin/. You should see the admin’s login screen:
That must mean I have to access the EC2's local domain on my computer, right? How should I go about doing this?
I've tried (with my correct address in the x's) "ec2-xx-xxx-xx-xx.us-west-2.compute.amazonaws.com/home/admin/", "ec2-xx-xxx-xx-xx.us-west-2.compute.amazonaws.com/admin/", and even using the user's directory I'm using "ec2-xx-xxx-xx-xx.us-west-2.compute.amazonaws.com/user/admin/".
I put the project in the user's folder, so it's in /home/user/my_django_project/
I've accessed and used EC2 successfully before by putting PHP and HTML projects in the /home/user/public_html/ folder, but I have no clue what to do for this.
Run the following command in the Django application folder:
python manage.py runserver 0.0.0.0:8000
Add a rule to your Security Group to allow Inbound TCP through port 8000. You can use a Custom TCP Rule to specify that only port 8000 be allowed in.
Open your browser and go to the following link:
http://<EC2_ADDRESS>.amazonaws.com:8000/admin/
The admin page should now load and you should be able to see the GET requests from your local computer on your Amazon server. e.g [29/Mar/2015 03:35:24] "GET /admin HTTP".
I guess you run Django via the manage.py runserver command? If so Django is currently only listening on 127.0.0.1. Start django using
manage.py runserver 0.0.0.0
in order for it to listen on all IPs. You should then, if configured properly, be able to reach it via "ec2-xx-xxx-xx-xx.us-west-2.compute.amazonaws.com:8000/admin/".
I am hosting a django-based site on a local machine (I have full access/control to it).
This site authenticates users against a remote active directory via the django ldap plugin.
authenticating against LDAP server used to work!
Now, when trying to authenticate against the LDAP server, the request just hangs until it times out. I couldn’t find anything useful in the logs.
The server setup is:
NginX, Django 1.3, Fedora 15, mySql 5.1.
I don’t know what logs I should try to look at.
(I've tried looking in nginx access and error logs but to no use.)
Things I tried:
Running the site on django's and accessing it via localhost (not going through Nginx, but accessing python manage.py directly, via the runserver command). this works
Running ldapsearch from the command line. this works
edit:
i used wireshark to look at the back-and-forth with the ldap server. the interaction seems to be fine - django sends a request to bind and it receives a success msg, and then sends a search query and a user object is returned. however, after this communication django seems to hang. when i "Ctrl-c" in the django shell after running "authenticate(username=user, password=pass)", the stack trace is sitting somewhere in the django-ldap library.
Please help, I have no idea what changed that caused this problem.
Thank you in advance
Active Directory does not allow anonymous binds for authorization; you can bind anonymously but you cannot do anything else.
Check if the user that is being used to bind with AD has valid credentials (ie, the account hasn't expired). If it has, you'll get these strange errors.