0

I'm trying to follow the tutorial at http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html. Following the directions I have:

(env1)ubuntu@ip-172-31-**-**:~/tproxy/tp$ uwsgi --http :8000 --wsgi-file test.py
*** Starting uWSGI 2.0.9 (64bit) on [Tue Mar  3 11:25:12 2015] ***
compiled with version: 4.8.2 on 03 March 2015 02:58:28
os: Linux-3.13.0-44-generic #73-Ubuntu SMP Tue Dec 16 00:22:43 UTC 2014
nodename: ip-172-31-**-**
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/ubuntu/tproxy/tp
detected binary path: /home/ubuntu/.virtualenvs/env1/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 7862
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 http bound on :8000 fd 4
spawned uWSGI http 1 (pid: 11221)
uwsgi socket 0 bound to TCP address 127.0.0.1:55522 (port auto-assigned) fd 3
Python version: 3.4.0 (default, Apr 11 2014, 13:08:40)  [GCC 4.8.2]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x786830
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72760 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
failed to open python file test.py
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 11220, cores: 1)

Since I'm on an ec2 ubuntu instance I tried the opening public and private ips at port 8000, eg http://172.31..*:8000/ , but the request times out. What am I doing wrong?

edit: I tried to make the changes you suggested. Here is the output:

(env1)ubuntu@ip-172-31-28-196:~$ ls
host_type.py  requirements.txt  test.py  tproxy
(env1)ubuntu@ip-172-31-28-196:~$ sudo chmod 666 test.py
(env1)ubuntu@ip-172-31-28-196:~$ uwsgi --http :8000 --wsgi-file test.py
*** Starting uWSGI 2.0.9 (64bit) on [Tue Mar  3 14:45:58 2015] ***
compiled with version: 4.8.2 on 03 March 2015 02:58:28
os: Linux-3.13.0-44-generic #73-Ubuntu SMP Tue Dec 16 00:22:43 UTC 2014
nodename: ip-172-31-28-196
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/ubuntu
detected binary path: /home/ubuntu/.virtualenvs/env1/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 7862
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)
probably another instance of uWSGI is running on the same address (:8000).
bind(): Address already in use [core/socket.c line 764]
(env1)ubuntu@ip-172-31-28-196:~$ ls -la
total 60
drwxr-xr-x 7 ubuntu ubuntu 4096 Mar  3 03:03 .
drwxr-xr-x 3 root   root   4096 Feb 20 22:20 ..
-rw------- 1 ubuntu ubuntu 1554 Mar  3 11:35 .bash_history
-rw-r--r-- 1 ubuntu ubuntu  220 Apr  9  2014 .bash_logout
-rw------- 1 ubuntu ubuntu 3751 Feb 27 19:49 .bashrc
drwx------ 3 ubuntu ubuntu 4096 Feb 27 21:08 .cache
-rw-rw-r-- 1 ubuntu ubuntu    0 Feb 23 17:15 host_type.py
drwxrwxr-x 2 ubuntu ubuntu 4096 Feb 25 18:02 .pip
-rw-r--r-- 1 ubuntu ubuntu  675 Apr  9  2014 .profile
-rw-rw-r-- 1 ubuntu ubuntu   73 Mar  2 02:35 requirements.txt
drwx------ 2 ubuntu ubuntu 4096 Feb 20 22:20 .ssh
-rw-rw-rw- 1 root   root    136 Mar  3 03:02 test.py
drwxrwxr-x 3 ubuntu ubuntu 4096 Mar  2 18:33 tproxy
-rw------- 1 ubuntu ubuntu 4119 Feb 27 19:51 .viminfo
drwxrwxr-x 3 ubuntu ubuntu 4096 Feb 28 02:17 .virtualenvs
(env1)ubuntu@ip-172-31-28-196:~$
user1592380
  • 34,265
  • 92
  • 284
  • 515

1 Answers1

1

It couldn't find test.py. Make sure it has permissions to the file. Did you make your virtuslenv with sudo? If so do a chmod and change the folder permissions to something your nginx and uwsgi has access to. Or it could be the path to the test.py file us wrong, double check that.

Jared Mackey
  • 3,998
  • 4
  • 31
  • 50
  • `probably another instance of uWSGI is running on the same address` seems to be your issue now. What is the root of your virtualenv? It is best to put all files related to it in side the folder of your virtual env to keep things nicely wrapped up. – Jared Mackey Mar 03 '15 at 15:37
  • /home/ubuntu/.virtualenvs/env1 – user1592380 Mar 03 '15 at 15:42
  • try rebooting and then moving the test.py file into that directory, activating and then running the uwsgi again. – Jared Mackey Mar 03 '15 at 15:54
  • In your aws console under your ec2 instances you should be able to right click on the instance and reboot it. – Jared Mackey Mar 03 '15 at 15:55
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/72162/discussion-between-electrometro-and-user61629). – Jared Mackey Mar 03 '15 at 16:00
  • Thank you, with the chat the basic test.py file is now working at the public ip address:8000 and the dns;8000 – user1592380 Mar 03 '15 at 16:35
  • I have a follow up at http://stackoverflow.com/questions/28842070/nginx-not-serving-django-image – user1592380 Mar 03 '15 at 21:19
  • Another follow up at http://stackoverflow.com/questions/28856878/setting-up-unix-socket-with-nginx-and-django if you have a chance – user1592380 Mar 04 '15 at 14:35