title: Gunicorn site not starting?
body: <p>First let me say that I am a Systems Engineer, but am learning WebDev/DevOps material, with a focus on Python.  Thus, I am in the process of moving my sites over from WordPress (PHP-based), to Mezzanine (Python-based).  To run multiple sites from one VPS, I am setting up VirtualEnv with Gunicorn, and Nginx on the front.  Since my day job is as a SysEngineer and I work with RHEL servers, CentOS 6 is my current web hosting platform of choice.  Here is what I have currently on a CentOS 6.5 server:</p>
  
  <pre><code>***INSTALL PYTHON 3.3.4, PIP, VIRTUALENV***
  yum groupinstall -y development
  yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel xz-libs
  wget http://www.python.org/ftp/python/3.3.4/Python-3.3.4.tar.xz
  xz -d Python-3.3.4.tar.xz
  tar -xvf Python-3.3.4.tar &amp;&amp; cd Python-3.3.4
  ./configure
  make &amp;&amp; make altinstall
  wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-2.2.tar.gz
  tar -xvf setuptools-2.2.tar.gz &amp;&amp; cd setuptools-2.2
  python3.3 setup.py install
  curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python3.3 -
  pip install virtualenv
  
  ***SETUP SITES &amp; GUNICORN***
  rm -rf /root/Python*
  rm -rf /root/setuptools*
  mkdir /sites &amp;&amp; mkdir /sites/sitename &amp;&amp; mkdir /sites/sitename/app &amp;&amp; cd /sites/sitename
  virtualenv sitename_venv
  source sitename_venv/bin/activate
  pip install gunicorn
  deactivate
  
  ***WSGI***
  cd /sites/sitename &amp;&amp; vi wsgi.py
  source sitename_venv/bin/activate
  source sitename_venv/bin/activate
  gunicorn -b 0.0.0.0:8081 --workers=5 wsgi:app
  </code></pre>
  
  <p>The last section (WSGI) is to test out Gunicorn, and wsgi.py looks like this:</p>
  
  <pre><code>def app(environ, start_response):
      """Simplest possible application object"""
      data = 'Hello, World!\n'
      status = '200 OK'
      response_headers = [
          ('Content-type','text/plain'),
          ('Content-Length', str(len(data)))
      ]
      start_response(status, response_headers)
      return iter([data])
  </code></pre>
  
  <p>So when I start the site, I see this:</p>
  
  <pre><code>(sitename_venv)[root@SERVER sitename]# gunicorn -b 0.0.0.0:8081 --workers=5 wsgi:app
  2014-02-22 13:13:07 [36417] [INFO] Starting gunicorn 18.0
  2014-02-22 13:13:07 [36417] [INFO] Listening at: http://0.0.0.0:8081 (36417)
  2014-02-22 13:13:07 [36417] [INFO] Using worker: sync
  2014-02-22 13:13:07 [36420] [INFO] Booting worker with pid: 36420
  2014-02-22 13:13:07 [36421] [INFO] Booting worker with pid: 36421
  2014-02-22 13:13:07 [36422] [INFO] Booting worker with pid: 36422
  2014-02-22 13:13:07 [36423] [INFO] Booting worker with pid: 36423
  2014-02-22 13:13:07 [36424] [INFO] Booting worker with pid: 36424
  </code></pre>
  
  <p>So the site should be running, but when I browse to it (IP:8081 -- from the same network, since this is a local VM and not my VPS yet) I just get "web page not available".  If I stop Gunicorn, I get "Chrome could not connect...blah, blah" so I know Gunicorn is responding to my http request.  What I don't know, is why I can't see what wsgi.py is supposed to be showing?  Any ideas?</p>
  
  <p>Nginx is not in the mix yet, so it's nothing with that config.  I'm still fairly new to virtualenv and python in general, so I wouldn't be surprised if my wsgi.py file has a problem.</p>
  
  <p>Thanks!</p>
  
  <p>EDIT1:</p>
  
  <pre><code>[root@SERVER ~]# curl -v http://0:8081
  * About to connect() to 0 port 8081 (#0)
  *   Trying 0.0.0.0... connected
  * Connected to 0 (0.0.0.0) port 8081 (#0)
  &gt; GET / HTTP/1.1
  &gt; User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
  &gt; Host: 0:8081
  &gt; Accept: */*
  &gt; 
  &lt; HTTP/1.1 200 OK
  &lt; Server: gunicorn/18.0
  &lt; Date: Sat, 22 Feb 2014 18:26:24 GMT
  &lt; Connection: close
  &lt; Content-type: text/plain
  &lt; Content-Length: 14
  &lt; 
  * transfer closed with 14 bytes remaining to read
  * Closing connection #0
  curl: (18) transfer closed with 14 bytes remaining to read
  </code></pre>