[GH-ISSUE #548] Debug=False causes resources not to be found #397

Closed
opened 2026-02-25 23:42:19 +03:00 by kerem · 3 comments
Owner

Originally created by @horschi on GitHub (Aug 3, 2021).
Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/548

Hi,

We set up our own healthchecks on Ubuntu 18.04 following the instructions in the Readme.

In Debug mode everything is working fine. But as soon as we switched debug=false, we got http 500 errors, which I think we solved by setting some missing properties and running "collectstatic" and "compress".

Now we a in a situation where it seems to basically work, but static resources are not being served (http 404 errors):

~/webapps/healthchecks$ ./manage.py runserver  
Performing system checks...

System check identified no issues (0 silenced).
August 03, 2021 - 13:56:58
Django version 3.2.6, using settings 'hc.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[03/Aug/2021 13:57:00] "GET / HTTP/1.0" 200 29314
[03/Aug/2021 13:57:00] "GET /static/CACHE/css/output.a7dd15ea236b.css HTTP/1.0" 404 179
[03/Aug/2021 13:57:00] "GET /static/img/logo.png HTTP/1.0" 404 179
[03/Aug/2021 13:57:00] "GET /static/CACHE/js/output.aa03829d4c7f.js HTTP/1.0" 404 179
[03/Aug/2021 13:57:00] "GET /static/img/my_checks.png HTTP/1.0" 404 179
[03/Aug/2021 13:57:00] "GET /static/img/period_grace.png HTTP/1.0" 404 179
[03/Aug/2021 13:57:00] "GET /static/img/cron.png HTTP/1.0" 404 179
[03/Aug/2021 13:57:00] "GET /static/img/check_details.png HTTP/1.0" 404 179
[03/Aug/2021 13:57:00] "GET /static/img/badges.png HTTP/1.0" 404 179
[03/Aug/2021 13:57:00] "GET /static/img/integrations/email.png HTTP/1.0" 404 179
[03/Aug/2021 13:57:00] "GET /static/img/integrations/webhook.png HTTP/1.0" 404 179
[03/Aug/2021 13:57:00] "GET /static/img/integrations/slack.png HTTP/1.0" 404 179
[03/Aug/2021 13:57:00] "GET /static/img/integrations/mattermost.png HTTP/1.0" 404 179
[03/Aug/2021 13:57:00] "GET /static/img/integrations/msteams.png HTTP/1.0" 404 179
[03/Aug/2021 13:57:00] "GET /static/img/integrations/opsgenie.png HTTP/1.0" 404 179
[03/Aug/2021 13:57:00] "GET /static/img/integrations/pd.png HTTP/1.0" 404 179
[03/Aug/2021 13:57:00] "GET /static/img/integrations/pagertree.png HTTP/1.0" 404 179
[03/Aug/2021 13:57:00] "GET /static/img/integrations/prometheus.png HTTP/1.0" 404 179
[03/Aug/2021 13:57:00] "GET /static/img/integrations/victorops.png HTTP/1.0" 404 179
[03/Aug/2021 13:57:00] "GET /static/img/integrations/spike.png HTTP/1.0" 404 179
[03/Aug/2021 13:57:00] "GET /static/img/integrations/zulip.png HTTP/1.0" 404 179
[03/Aug/2021 13:57:01] "GET /static/img/favicon.ico HTTP/1.0" 404 179
[03/Aug/2021 13:57:12] "POST /ping/ad50725a-...-f7036cccf411 HTTP/1.0" 200 2
[03/Aug/2021 13:57:13] "POST /ping/471f6b64-...-c58b9e41b5c1 HTTP/1.0" 200 2

As you can see, the REST calls work fine, its only resources that are not being served! if we switch back to debug mode, then it works fine again.

Our config file looks as follows:

SITE_ROOT = "https://health.xxx.com"
SITE_NAME = "XXX health"
DEFAULT_FROM_EMAIL = "monitoring@xxx.cloud"
DEBUG = False
REGISTRATION_OPEN = False
#ALLOWED_HOSTS = ["health.xxx.com","localhost"]
ALLOWED_HOSTS = ["*"]
CSRF_TRUSTED_ORIGINS = ["health.xxx.com","localhost"]

# Email
EMAIL_HOST = "xxx"
EMAIL_PORT = 587
EMAIL_HOST_USER = "xxxx"
EMAIL_HOST_PASSWORD = "xxx"
EMAIL_USE_TLS = True

PING_ENDPOINT = SITE_ROOT + "/ping/"
ADMINS = (  
            ('backoffice', 'backoffice@xxx.com'),
            )
SECRET_KEY = "xxx"
COMPRESS_OFFLINE = True
#STATIC_URL = 'static/'
#STATIC_ROOT = "/home/healthchecks/webapps/healthchecks/static/"

Our files on disk also look good to us:

healthchecks@dev:~/webapps/healthchecks$ ls -alph static/
total 24K
drwxrwxr-x  6 healthchecks healthchecks 4.0K Aug  3 13:56 ./
drwxrwxr-x 11 healthchecks healthchecks 4.0K Aug  3 14:01 ../
drwxrwxr-x  3 healthchecks healthchecks 4.0K Aug  2 10:21 css/
drwxrwxr-x  2 healthchecks healthchecks 4.0K Aug  2 10:21 fonts/
drwxrwxr-x  4 healthchecks healthchecks 4.0K Aug  2 10:21 img/
drwxrwxr-x  2 healthchecks healthchecks 4.0K Aug  2 10:21 js/
healthchecks@dev:~/webapps/healthchecks$ ls -alph static-collected/
total 32K
drwxrwxr-x  8 healthchecks healthchecks 4.0K Aug  3 13:30 ./
drwxrwxr-x 11 healthchecks healthchecks 4.0K Aug  3 14:01 ../
drwxrwxr-x  4 healthchecks healthchecks 4.0K Aug  3 13:42 CACHE/
drwxrwxr-x  6 healthchecks healthchecks 4.0K Aug  3 13:30 admin/
drwxrwxr-x  3 healthchecks healthchecks 4.0K Aug  3 13:30 css/
drwxrwxr-x  2 healthchecks healthchecks 4.0K Aug  3 13:30 fonts/
drwxrwxr-x  4 healthchecks healthchecks 4.0K Aug  3 13:30 img/
drwxrwxr-x  2 healthchecks healthchecks 4.0K Aug  3 13:30 js/

We cannot think of anything else to check, so perhaps your have at least a hint for us what to check for? Or is it perhaps even some bug?

Thanks a lot in advance,
Christian and Ales :-)

Originally created by @horschi on GitHub (Aug 3, 2021). Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/548 Hi, We set up our own healthchecks on Ubuntu 18.04 following the instructions in the Readme. In Debug mode everything is working fine. But as soon as we switched debug=false, we got http 500 errors, which I think we solved by setting some missing properties and running "collectstatic" and "compress". Now we a in a situation where it seems to basically work, but static resources are not being served (http 404 errors): ``` ~/webapps/healthchecks$ ./manage.py runserver Performing system checks... System check identified no issues (0 silenced). August 03, 2021 - 13:56:58 Django version 3.2.6, using settings 'hc.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. [03/Aug/2021 13:57:00] "GET / HTTP/1.0" 200 29314 [03/Aug/2021 13:57:00] "GET /static/CACHE/css/output.a7dd15ea236b.css HTTP/1.0" 404 179 [03/Aug/2021 13:57:00] "GET /static/img/logo.png HTTP/1.0" 404 179 [03/Aug/2021 13:57:00] "GET /static/CACHE/js/output.aa03829d4c7f.js HTTP/1.0" 404 179 [03/Aug/2021 13:57:00] "GET /static/img/my_checks.png HTTP/1.0" 404 179 [03/Aug/2021 13:57:00] "GET /static/img/period_grace.png HTTP/1.0" 404 179 [03/Aug/2021 13:57:00] "GET /static/img/cron.png HTTP/1.0" 404 179 [03/Aug/2021 13:57:00] "GET /static/img/check_details.png HTTP/1.0" 404 179 [03/Aug/2021 13:57:00] "GET /static/img/badges.png HTTP/1.0" 404 179 [03/Aug/2021 13:57:00] "GET /static/img/integrations/email.png HTTP/1.0" 404 179 [03/Aug/2021 13:57:00] "GET /static/img/integrations/webhook.png HTTP/1.0" 404 179 [03/Aug/2021 13:57:00] "GET /static/img/integrations/slack.png HTTP/1.0" 404 179 [03/Aug/2021 13:57:00] "GET /static/img/integrations/mattermost.png HTTP/1.0" 404 179 [03/Aug/2021 13:57:00] "GET /static/img/integrations/msteams.png HTTP/1.0" 404 179 [03/Aug/2021 13:57:00] "GET /static/img/integrations/opsgenie.png HTTP/1.0" 404 179 [03/Aug/2021 13:57:00] "GET /static/img/integrations/pd.png HTTP/1.0" 404 179 [03/Aug/2021 13:57:00] "GET /static/img/integrations/pagertree.png HTTP/1.0" 404 179 [03/Aug/2021 13:57:00] "GET /static/img/integrations/prometheus.png HTTP/1.0" 404 179 [03/Aug/2021 13:57:00] "GET /static/img/integrations/victorops.png HTTP/1.0" 404 179 [03/Aug/2021 13:57:00] "GET /static/img/integrations/spike.png HTTP/1.0" 404 179 [03/Aug/2021 13:57:00] "GET /static/img/integrations/zulip.png HTTP/1.0" 404 179 [03/Aug/2021 13:57:01] "GET /static/img/favicon.ico HTTP/1.0" 404 179 [03/Aug/2021 13:57:12] "POST /ping/ad50725a-...-f7036cccf411 HTTP/1.0" 200 2 [03/Aug/2021 13:57:13] "POST /ping/471f6b64-...-c58b9e41b5c1 HTTP/1.0" 200 2 ``` As you can see, the REST calls work fine, its only resources that are not being served! if we switch back to debug mode, then it works fine again. Our config file looks as follows: ``` SITE_ROOT = "https://health.xxx.com" SITE_NAME = "XXX health" DEFAULT_FROM_EMAIL = "monitoring@xxx.cloud" DEBUG = False REGISTRATION_OPEN = False #ALLOWED_HOSTS = ["health.xxx.com","localhost"] ALLOWED_HOSTS = ["*"] CSRF_TRUSTED_ORIGINS = ["health.xxx.com","localhost"] # Email EMAIL_HOST = "xxx" EMAIL_PORT = 587 EMAIL_HOST_USER = "xxxx" EMAIL_HOST_PASSWORD = "xxx" EMAIL_USE_TLS = True PING_ENDPOINT = SITE_ROOT + "/ping/" ADMINS = ( ('backoffice', 'backoffice@xxx.com'), ) SECRET_KEY = "xxx" COMPRESS_OFFLINE = True #STATIC_URL = 'static/' #STATIC_ROOT = "/home/healthchecks/webapps/healthchecks/static/" ``` Our files on disk also look good to us: ``` healthchecks@dev:~/webapps/healthchecks$ ls -alph static/ total 24K drwxrwxr-x 6 healthchecks healthchecks 4.0K Aug 3 13:56 ./ drwxrwxr-x 11 healthchecks healthchecks 4.0K Aug 3 14:01 ../ drwxrwxr-x 3 healthchecks healthchecks 4.0K Aug 2 10:21 css/ drwxrwxr-x 2 healthchecks healthchecks 4.0K Aug 2 10:21 fonts/ drwxrwxr-x 4 healthchecks healthchecks 4.0K Aug 2 10:21 img/ drwxrwxr-x 2 healthchecks healthchecks 4.0K Aug 2 10:21 js/ healthchecks@dev:~/webapps/healthchecks$ ls -alph static-collected/ total 32K drwxrwxr-x 8 healthchecks healthchecks 4.0K Aug 3 13:30 ./ drwxrwxr-x 11 healthchecks healthchecks 4.0K Aug 3 14:01 ../ drwxrwxr-x 4 healthchecks healthchecks 4.0K Aug 3 13:42 CACHE/ drwxrwxr-x 6 healthchecks healthchecks 4.0K Aug 3 13:30 admin/ drwxrwxr-x 3 healthchecks healthchecks 4.0K Aug 3 13:30 css/ drwxrwxr-x 2 healthchecks healthchecks 4.0K Aug 3 13:30 fonts/ drwxrwxr-x 4 healthchecks healthchecks 4.0K Aug 3 13:30 img/ drwxrwxr-x 2 healthchecks healthchecks 4.0K Aug 3 13:30 js/ ``` We cannot think of anything else to check, so perhaps your have at least a hint for us what to check for? Or is it perhaps even some bug? Thanks a lot in advance, Christian and Ales :-)
kerem closed this issue 2026-02-25 23:42:19 +03:00
Author
Owner

@cuu508 commented on GitHub (Aug 3, 2021):

Hi Christian and Ales,

Django apps serve static files during development, but in production it is expected the static files will be served separately by a web server. See the Django docs here:

https://docs.djangoproject.com/en/3.2/howto/static-files/deployment/

Looking at the Healthchecks' README, there's no mention of serving static files, I'll look into improving the README. As a minimum, link to the above page.

If you plan to put nginx, apache, caddy or another web server in front of your Healthchecks instance, you can configure the web server to serve static files from ~/webapps/healthchecks/static-collected/.

Another option is to use whitenoise, but this requires changing settings.py. I'll look into adding whitenoise in the default configuration – it would be nice if static files worked out of the box.

<!-- gh-comment-id:891940763 --> @cuu508 commented on GitHub (Aug 3, 2021): Hi Christian and Ales, Django apps serve static files during development, but in production it is expected the static files will be served separately by a web server. See the Django docs here: https://docs.djangoproject.com/en/3.2/howto/static-files/deployment/ Looking at the Healthchecks' README, there's no mention of serving static files, I'll look into improving the README. As a minimum, link to the above page. If you plan to put nginx, apache, caddy or another web server in front of your Healthchecks instance, you can configure the web server to serve static files from ~/webapps/healthchecks/static-collected/. Another option is to use [whitenoise](http://whitenoise.evans.io/en/stable/index.html), but this requires changing settings.py. I'll look into adding whitenoise in the default configuration – it would be nice if static files worked out of the box.
Author
Owner

@horschi commented on GitHub (Aug 3, 2021):

Yes, that was it. It was not clear that the files are not served. Thanks!

For others reading this, we use NGinx to serve and now use the following configuration:

        location / {
                proxy_pass http://127.0.0.1:8000;
                proxy_set_header    Host             $http_host;
                proxy_set_header    X-Real-IP        $remote_addr;
                proxy_set_header    X-Forwarded-For  $proxy_add_x_forwarded_for;
        }

        location /static {
                alias /home/healthchecks/webapps/healthchecks/static-collected/;
        }
<!-- gh-comment-id:891969644 --> @horschi commented on GitHub (Aug 3, 2021): Yes, that was it. It was not clear that the files are not served. Thanks! For others reading this, we use NGinx to serve and now use the following configuration: ``` location / { proxy_pass http://127.0.0.1:8000; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /static { alias /home/healthchecks/webapps/healthchecks/static-collected/; } ```
Author
Owner

@cuu508 commented on GitHub (Aug 5, 2021):

I plan to update README a bit, and look into using whitenoise. I'll keep this issue open until that's done so I don't forget.

<!-- gh-comment-id:893259519 --> @cuu508 commented on GitHub (Aug 5, 2021): I plan to update README a bit, and look into using whitenoise. I'll keep this issue open until that's done so I don't forget.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/healthchecks#397
No description provided.