title: Django Runserver with SSL
body: <p>I've been trying to follow the instructions for using django runserver with ssl through stunnel listed here:</p>
  
  <p><a href="https://stackoverflow.com/questions/8023126/how-can-i-test-https-connections-with-django-as-easily-as-i-can-non-https-connec">How can I test https connections with Django as easily as I can non-https connections using &#39;runserver&#39;?</a></p>
  
  <p>but am having some trouble. I have stunnel and both runservers each running in a virtual environment. Each seems to be working by iteself.</p>
  
  <p>stunnel.pem looks like this :</p>
  
  <pre><code>-----BEGIN RSA PRIVATE KEY-----
  (random)
  -----END RSA PRIVATE KEY-----
  -----BEGIN CERTIFICATE-----
  (random)
  -----END CERTIFICATE-----
  </code></pre>
  
  <p>dev_https looks like this:</p>
  
  <pre><code>pid=
  
  cert = stunnel/stunnel.pem
  sslVersion = SSLv3
  foreground = yes
  output = stunnel.log
  
  [https]
  accept=8443
  connect=8001
  TIMEOUTclose=1
  </code></pre>
  
  <p>When I attempt to access </p>
  
  <pre><code>https://127.0.0.1:8443/ 
  </code></pre>
  
  <p>here's what happens:</p>
  
  <p>Stunnel, executed with:</p>
  
  <pre><code>stunnel4 dev_https
  </code></pre>
  
  <p>shows this:</p>
  
  <pre><code>2012.08.23 20:20:58 LOG5[3818:140280034400000]: Service https accepted connection from 127.0.0.1:44302
  2012.08.23 20:20:58 LOG5[3818:140280034400000]: connect_blocking: connected 127.0.0.1:8001
  2012.08.23 20:20:58 LOG5[3818:140280034400000]: Service https connected remote server from 127.0.0.1:34622
  2012.08.23 20:20:58 LOG5[3818:140280034400000]: Connection closed: 187 bytes sent to SSL, 422 bytes sent to socket
  </code></pre>
  
  <p>The server executed with:</p>
  
  <pre><code>python2.7 manage.py runserver
  </code></pre>
  
  <p>shows:</p>
  
  <pre><code>(nothing)
  </code></pre>
  
  <p>The server executed with:</p>
  
  <pre><code>HTTPS=1 python2.7 managpy runserver 8001
  </code></pre>
  
  <p>shows:</p>
  
  <pre><code>[23/Aug/2012 19:20:58] "GET / HTTP/1.1" 301 0
  </code></pre>
  
  <p>Finally, the web page request in the browser shows a standard chrome error:</p>
  
  <pre><code>This webpage is not available
  The server at 127.0.0.1 can't be found, because the DNS lookup failed.
  </code></pre>
  
  <p>I'd appreciate any advice on what I can change or what I'm doing wrong. Thank you for your help!</p>
  
  <p><strong>UPDATE</strong>
  I'm now getting this error message:</p>
  
  <pre><code>----------------------------------------
  Exception happened during processing of request from ('127.0.0.1', 52878)  
  Traceback (most recent call last):
    File "/usr/lib/python2.7/SocketServer.py", line 582, in process_request_thread
      self.finish_request(request, client_address)
    File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
      self.RequestHandlerClass(request, client_address, self)
    File "/usr/local/lib/python2.7/dist-packages/django/core/servers/basehttp.py", line 139, in __init__
      super(WSGIRequestHandler, self).__init__(*args, **kwargs)
    File "/usr/lib/python2.7/SocketServer.py", line 638, in __init__
  self.handle()
     File "/usr/lib/python2.7/wsgiref/simple_server.py", line 116, in handle
  self.raw_requestline = self.rfile.readline()
    File "/usr/lib/python2.7/socket.py", line 447, in readline
  data = self._sock.recv(self._rbufsize)
  error: [Errno 104] Connection reset by peer
   ----------------------------------------
  </code></pre>