Super basic uwsgi configuration
Question: I've tried some uwsgi tutorials but can't get a simple python script to run in
my browser. Ive read through this (<http://uwsgi-
docs.readthedocs.org/en/latest/WSGIquickstart.html>) and this
(<https://www.digitalocean.com/community/articles/how-to-deploy-python-wsgi-
applications-using-uwsgi-web-server-with-nginx>) and others, but for some
reason can't get a simple uwsgi app running. I am currently not going through
a web server, just uwsgi by itself.

I have the following wsgi.py:

    
    
    def application(env, start_response):
        start_response('200 OK', [('Content-Type', 'text/html')])
    return ["Hello!"]
    

and I run:

    
    
    uwsgi --socket 127.0.0.1:8080 --chdir /my/program/path --pp .. -w wsgi
    

which produces the following output (looks promising):

    
    
    *** Starting uWSGI 2.0.3 (64bit) on [Mon Apr 14 12:51:32 2014] ***
    compiled with version: 4.6.3 20120306 (Red Hat 4.6.3-2) on 14 April 2014 12:01:33
    os: Linux-3.1.0-7.fc16.x86_64 #1 SMP Tue Nov 1 21:10:48 UTC 2011
    nodename: ip-10-252-98-215
    machine: x86_64
    clock source: unix
    detected number of CPU cores: 1
    current working directory: /usr/oai/icscada/www
    detected binary path: /usr/bin/uwsgi
    !!! no internal routing support, rebuild with pcre support !!!
    uWSGI running as root, you can use --uid/--gid/--chroot options
    *** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
    *** WARNING: you are running uWSGI without its master process manager ***
    your processes number limit is 1024
    your memory page size is 4096 bytes
    detected max file descriptor number: 1024
    lock engine: pthread robust mutexes
    thunder lock: disabled (you can enable it with --thunder-lock)
    uwsgi socket 0 bound to TCP address 127.0.0.1:8080 fd 3
    Python version: 2.7.3 (default, Jul 24 2012, 11:41:40)  [GCC 4.6.3 20120306 (Red Hat 4.6.3-2)]
    *** Python threads support is disabled. You can enable it with --enable-threads ***
    Python main interpreter initialized at 0x2504ee0
    your server socket listen backlog is limited to 100 connections
    your mercy for graceful operations on workers is 60 seconds
    mapped 72752 bytes (71 KB) for 1 cores
    *** Operational MODE: single process ***
    added ../ to pythonpath.
    WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x2504ee0 pid: 21702 (default app)
    *** uWSGI is running in multiple interpreter mode ***
    spawned uWSGI worker 1 (and the only) (pid: 21702, cores: 1)
    

but when I go to port 8080 from my browser I get a "could not connect" error.
Port 8080 is open and has been tested.

* * *

I've also tried the following wsgi.py:

    
    
    import os
    os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
    import django.core.handlers.wsgi
    application = django.core.handlers.wsgi.WSGIHandler()
    

exactly the same results


Answer: If you want to run uWSGI without a web server in front of it, use `http`
option instead of `socket`. See [Native HTTP support](http://uwsgi-
docs.readthedocs.org/en/latest/HTTP.html).

Also, use 0.0.0.0:80 as an address if you are accessing from a remote machine.

