Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Updated Code - this is still not working though.

STATIC_ROOT = '/home/ubuntu/virtualenv/mysite/homelaunch/static/'
STATIC_URL = '/static/'

nginx conf :: /etc/nginx/sites-enabled/mysite

server {
        access_log /home/ubuntu/virtualenv/mysite/error/access.log;
        error_log /home/ubuntu/virtualenv/mysite/error/error.log warn;
        connection_pool_size 2048;

        location /static/ {
            #alias /home/ubuntu/virtualenv/mysite/homelaunch/static/;
            #alias /static/;
            root /home/ubuntu/virtualenv/mysite/homelaunch/;

        location / {
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            #proxy_set_header X-Forwarded-Host $server_name;
            #proxy_set_header X-Real-IP $remote_addr;
            add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';

gunicorn config -

command = '/usr/local/bin/gunicorn'
logfile = "/home/ubuntu/virtualenv/mysite/error/gunicorn.log"
loglevel = "info"
pythonpath = '/home/ubuntu/virtualenv/mysite'
bind = ''

full path to img dir and css dir:


Receiving an error in the error.log:

001/favicon.ico", host: ""
2013/09/02 16:57:42 [error] 2819#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xx.xx.xx, server:, request: "GET / HTTP/1.1", upstream: "", host: ""

Anything that is glaringly wrong? I'm still getting a 404 error on both img and css files when I try to view them through the outputted html source.

share|improve this question
The configuration seems fine to me, does the file /home/ubuntu/virtualenv/mysite/homelaunch/img/templated/base/LogoV1.png actually exist ? – Changaco Sep 1 '13 at 14:51
No it doesn't. /home/ubuntu/virtualenv/mysite/homelaunch/static/img/templated/base/LogoV1.png does . This is missing the static dir after homelaunch dir . So what do I have to modify? If you could please specify in an answer I will try it out – user700070 Sep 1 '13 at 14:54
Does STATIC_ROOT = '/mysite/homelaunch/' have to change to: STATIC_ROOT = '/mysite/homelaunch/static/' ? – user700070 Sep 1 '13 at 14:57
additionally, i tried this as well ^^ and it didnt fix anything. It ALWAYS loads the template, but will not load the static files: img, css, etc . – user700070 Sep 1 '13 at 15:26
yeah I've run this portion of it already too – user700070 Sep 1 '13 at 15:43
up vote 1 down vote accepted

This answer has been edited to summarize the solutions.

In the configuration of nginx


alias /home/ubuntu/virtualenv/mysite/homelaunch/;


root /home/ubuntu/virtualenv/mysite/homelaunch/;

See the documentation for more details.


proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;


proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

In gunicorn's config


bind = ''


bind = ''

In django's settings

Setting STATIC_ROOT = '/home/ubuntu/virtualenv/mysite/homelaunch/static/' which is the correct absolute filesystem path.

Setting DEBUG = True to have more detailed error information.

share|improve this answer
yes and gunicorn – user700070 Sep 1 '13 at 15:25
yes it does ! This is so weird ha – user700070 Sep 1 '13 at 15:42
Thank you very much for the reply! I tried testing this, but nothing has changed the img and css are not appearing. I updated my question with even more detail - could you see if you see if anything is wrong ? I'm going to try look at the documentation some more myself. Thank you for your help thus far ! – user700070 Sep 2 '13 at 16:13
gunicorn conf is updated above - now my site isn't loading lol. – user700070 Sep 2 '13 at 17:12
Does this tell you anything? – user700070 Sep 2 '13 at 17:35

Replace this:

location /static/ {
            alias /home/ubuntu/virtualenv/mysite/homelaunch/;

For this one:

location /static/ {
            alias  /home/ubuntu/virtualenv/mysite/homelaunch/static/;

If you do a alias you need put absolute path, because you have defined static dir on

STATIC_URL = '/static/'

So if you put alias this dir /home/ubuntu/virtualenv/mysite/homelaunch/;

Nginx think the statics files are on /home/ubuntu/virtualenv/mysite/homelaunch/ and not in /home/ubuntu/virtualenv/mysite/homelaunch/static

Sorry for my bad english, i try to improve :(

I hope you understand me.

share|improve this answer
This does the same thing as replacing alias by root, so it won't help more than my answer. – Changaco Sep 1 '13 at 16:06
Not is the same, because on django he have defindes satatic files on /static/ so if change alias for correct dir stil work, he have alias defines for orther dir not for statics: location /static/ { alias /home/ubuntu/virtualenv/mysite/homelaunch/; } So this solution is if he have their statics on /home/ubuntu/virtualenv/mysite/homelaunch/statics – Skamasle Sep 1 '13 at 16:12
@Skamasle - please see updated code and give your thoughts. I would really appreciate it – user700070 Sep 1 '13 at 16:40
So and now working ? May point is only than you need define the alias on same dir when you have statics.., so I hope that works if not give us some lines of your error logs, and your dir distribution so what are on /home/ubuntu/virtualenv/mysite/homelaunch/ and on /home/ubuntu/virtualenv/mysite/ and on what dir you have your statics etc I have a django setup for some of my clients whit similar alias, and work very well. – Skamasle Sep 1 '13 at 18:08
@Skamasle - what do you need from me? – user700070 Sep 2 '13 at 1:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.