By eccleshall
Im following this tutorial to the letter but I’m having problems with the application I’m getting 502 Nginx error
could someone help? I’ve been trying to rectify this for sometime now but i can see a way of fixing it. so thought id ask here.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
If you could provide some more information, it would make it easier for us to know what the issue might be. Could you post any error messages in your nginx and uwsgi logs? Following the tutorial that you linked, they would be in: <br> <br> /var/www/example.com/logs/error.log <br> /var/log/uwsgi/example_project.log <br> <br>The nginx log’s default location is /var/log/nginx/error.log
@astarr sure, <br> <br>************************************************************************************ <br>/var/www/example.com/conf/nginx.conf <br>************************************************************************************ <br> <br>server { <br> listen 80; <br> server_name khcardsonline.co.uk www.khcardsonline.co.uk; <br> root /var/www/example.com/src/khcards; <br> access_log /var/www/example.com/logs/access.log; <br> error_log /var/www/example.com/logs/error.log; <br> <br> location /static/ { # STATIC_URL <br> alias /var/www/example.com/src/static/static/; # STATIC_ROOT <br> expires 30d; <br> } <br> <br> location /media/ { # MEDIA_URL <br> alias /var/www/example.com/src/media/; # MEDIA_ROOT <br> expires 30d; <br> } <br> <br> location / { <br> include uwsgi_params; <br> uwsgi_pass 127.0.0.1:8889; <br> } <br>} <br> <br> <br>************************************************************************************ <br>/var/www/example.com/conf/uwsgi.ini <br>************************************************************************************ <br> <br>[uwsgi] <br># variables <br>projectdomain = khcardsonline.co.uk www.khcardsonline.co.uk <br> <br>uid = www-data <br>god = www-data <br>chmod = 775 <br> <br># config <br>plugins = python <br>master = true <br>pidfile=/tmp/project-master.pid <br>protocol = uwsgi <br>env = DJANGO_SETTINGS_MODULE=khcards.settings <br>pythonpath = /var/www/example.com/src/khcards <br>module = khcards.wsgi:application <br>socket = 127.0.0.1:8889 <br>logto = /var/www/example.com/src/logs/uwsgi.log <br>#below line runs it as a daemon in background <br>daemonize = /var/log/uwsgi/khcards.log <br> <br>************************************************************************************ <br>/var/www/example.com/logs/uwsgi.log <br>************************************************************************************ <br> <br>*** Starting uWSGI 1.0.3-debian (64bit) on [Wed Apr 16 08:57:08 2014] *** <br>compiled with version: 4.6.3 on 17 July 2012 02:26:54 <br>current working directory: /var/www/example.com <br>detected binary path: /usr/bin/uwsgi-core <br>uWSGI running as root, you can use --uid/–gid/–chroot options <br>*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** <br>your memory page size is 4096 bytes <br>uwsgi socket 0 inherited INET address 127.0.0.1:8889 fd 4 <br>Python version: 2.7.3 (default, Feb 27 2014, 20:09:21) [GCC 4.6.3] <br>Python main interpreter initialized at 0x2457ed0 <br>your server socket listen backlog is limited to 100 connections <br>*** Operational MODE: single process *** <br>added /var/www/example.com/src/khcards/ to pythonpath. <br>ImportError: No module named khcards.wsgi <br>unable to load app 0 (mountpoint=‘’) (callable not found or import error) <br>*** no app loaded. going in full dynamic mode *** <br>*** uWSGI is running in multiple interpreter mode *** <br>gracefully (RE)spawned uWSGI master process (pid: 12881) <br>spawned uWSGI worker 1 (pid: 14856, cores: 1) <br> <br> <br>************************************************************************************ <br>/var/www/example.com/logs/error.log sample <br>************************************************************************************ <br>2014/04/16 08:59:00 [error] 787#0: 1 connect() failed (111: Connection refused) while connecting to upstream, client: 200.29.238.180, server: khcardsonline.co.uk, request: “HEAD / HTTP/1.0”, upstream: “uwsgi://127.0.0.1:8889” <br> <br>*********************************************************************************** <br>/var/log/uwsgi/logs/example_project.log <br>************************************************************************************ <br> <br>*** Starting uWSGI 1.0.3-debian (64bit) on [Wed Apr 16 08:32:32 2014] *** <br>compiled with version: 4.6.3 on 17 July 2012 02:26:54 <br>current working directory: /var/www/example.com <br>detected binary path: /usr/bin/uwsgi-core <br>uWSGI running as root, you can use --uid/–gid/–chroot options <br>*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** <br>your memory page size is 4096 bytes <br>uwsgi socket 0 bound to TCP address 127.0.0.1:8889 fd 4 <br>Python version: 2.7.3 (default, Feb 27 2014, 20:09:21) [GCC 4.6.3] <br>Python main interpreter initialized at 0x1286f10 <br>your server socket listen backlog is limited to 100 connections <br>*** Operational MODE: single process *** <br>added /var/www/example.com/src/khcards to pythonpath. <br>ImportError: No module named khcards.wsgi <br>unable to load app 0 (mountpoint=‘’) (callable not found or import error) <br>*** no app loaded. going in full dynamic mode *** <br>*** uWSGI is running in multiple interpreter mode *** <br>spawned uWSGI master process (pid: 12881) <br>spawned uWSGI worker 1 (pid: 12882, cores: 1) <br>[pid: 12882|app: -1|req: -1/1] 81.111.153.236 () {36 vars in 584 bytes} [Wed Apr 16 08:32:47 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/2] 81.111.153.236 () {38 vars in 585 bytes} [Wed Apr 16 08:32:47 2014] GET /favicon.ico => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/3] 81.111.153.236 () {36 vars in 569 bytes} [Wed Apr 16 08:32:49 2014] GET /apple-touch-icon-precomposed.png => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/4] 81.111.153.236 () {36 vars in 545 bytes} [Wed Apr 16 08:32:49 2014] GET /apple-touch-icon.png => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/5] 81.111.153.236 () {36 vars in 584 bytes} [Wed Apr 16 08:33:12 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/6] 81.111.153.236 () {38 vars in 585 bytes} [Wed Apr 16 08:33:12 2014] GET /favicon.ico => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/7] 81.111.153.236 () {36 vars in 569 bytes} [Wed Apr 16 08:33:14 2014] GET /apple-touch-icon-precomposed.png => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/8] 81.111.153.236 () {36 vars in 545 bytes} [Wed Apr 16 08:33:14 2014] GET /apple-touch-icon.png => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/9] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:37:39 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/10] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:42:02 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/11] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:42:03 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/12] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:42:04 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/13] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:42:04 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/14] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:42:04 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/15] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:42:05 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/16] 115.239.248.112 () {34 vars in 486 bytes} [Wed Apr 16 08:43:25 2014] GET /manager/html => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/17] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:50:11 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/18] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:50:13 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/19] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:50:13 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/20] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:50:13 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/21] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:50:14 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/22] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:50:14 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/23] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:50:14 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/24] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:50:14 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/25] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:50:14 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/26] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:50:15 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/27] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:50:15 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/28] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:51:40 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/29] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:51:42 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/30] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:51:44 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/31] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:51:44 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/32] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:51:44 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/33] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:56:40 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/34] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:56:41 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/35] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:56:42 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/36] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:56:42 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/37] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:56:42 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/38] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:56:42 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/39] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:56:42 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/40] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:56:43 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/41] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:56:43 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/42] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:56:43 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/43] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:56:43 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/44] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:56:43 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/45] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:56:43 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/46] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:56:44 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>[pid: 12882|app: -1|req: -1/47] 81.111.153.236 () {38 vars in 651 bytes} [Wed Apr 16 08:56:44 2014] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0) <br>…brutally killing workers… <br>binary reloading uWSGI… <br>chdir() to /var/www/example.com <br>closing all non-uwsgi socket fds > 2 (_SC_OPEN_MAX = 1024)… <br>found fd 4 mapped to socket 0 (127.0.0.1:8889) <br>running /usr/bin/uwsgi-core <br>[uWSGI] getting INI configuration from /var/www/example.com/conf/uwsgi.ini <br> <br>Let me know if you would like anything else <br>
Is there a wsgi.py file in you Django project? It doesn’t seem to be getting imported: <br> <br><pre> <br>added /var/www/example.com/src/khcards to pythonpath. <br>ImportError: No module named khcards.wsgi <br>unable to load app 0 (mountpoint=‘’) (callable not found or import error) <br>*** no app loaded. going in full dynamic mode *** <br></pre>
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.