Django server not displaying app


#1

My problem is perhaps related to this one. I’ve installed Django (1.11) in a virtualenv/virtualenvwrapper. I have Django’s built-in dev server running from the console (using the command "python manage.py runserver $IP:$PORT"). This throws no errors, giving me the usual message:

System check identified no issues (0 silenced).
October 24, 2017 - 22:32:08
Django version 1.11.6, using settings 'myapp.settings'
Starting development server at http://0.0.0.0:8080/
Quit the server with CONTROL-C.

The Cloud9 message even appears, indicating that my code is running at c9users.io. But when I load that preview URL in a browser, nothing appears. I get an “ERR_CONNECTION_REFUSED” message, just letting me know the site can’t be reached. (Weirdly, this behavior has been intermittent. Sometimes, the preview loads just fine, only to hang moments later, even if I haven’t changed a line of code. I haven’t been able to figure out what’s changed between it working and not working.)

I can deploy from Cloud9 to my production server just fine, and the code runs in the production environment as it should. But as you might imagine, not having a development environment with preview functionality kinda makes my IDE useless. (I’m currently deploying just to confirm that my edits work, which isn’t ideal.)

I tried cloning my workspace, and the same problems presented themselves on the clone.

One thing that might offer a clue: When I try to run the code using the RUN button, I get this traceback:

Traceback (most recent call last):
  File "/home/ubuntu/workspace/myapp/myapp/myapp/views.py", line 1, in <module>
    from django.shortcuts import render, get_object_or_404
ImportError: No module named 'django'

Any ideas about what might be happening? Thanks much.


#2

Just to add a bit more context: I’ve anecdotally observed that the server seems to work most reliably in “off hours” here in Eastern Time. For example, it wasn’t working when I posted this yesterday at 6:45 p.m. ET, however, I caught it working around 10 p.m. ET, and again this morning before 8 a.m. ET. It’s working at the moment, but who knows when it will blink off again. I can’t detect any CPU or RAM spikes that might correlate with its performance.