Your data. Anywhere you go.

New Relic for iOS or Android

Download on the App Store    Android App on Google play

New Relic Insights App for iOS

Download on the App Store

Learn more

Close icon

Django New Relic Systemd service Not working



Unable to collect any data into newrelic.
Running on Ubuntu 16.04.1 LTS, Django==2.0, gunicorn==19.6.0, newrelic==

Following is the /etc/systemd/system/gunicorn.service file

Description=gunicorn daemon

ExecStart=/PATH/TO/venv/bin/newrelic-admin run-program /PATH/TO/venv/bin/gunicorn --workers 3 --timeout 1800 --bind unix:/PATH/TO/project.sock project.wsgi:application --access-logfile /var/log/gunicorn_project/access.log --error-logfile /var/log/gunicorn_project/error.log


I have tested the config file, and it works. newrelic-admin validate-config newrelic.ini.
Also, no errors as such while running the gunicorn.service.

systemctl status gunicorn gives

ubuntu@XX-X-XX-XXX:~$ systemctl status gunicorn
● gunicorn.service - gunicorn daemon
   Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2018-02-10 06:17:20 UTC; 23min ago

Still no data inside the APM.


@anurag722 Thanks for you post and also for opening the support ticket regarding this issue. In the support ticket, I asked for clarification on whether your Django app was getting traffic during the time your collected agent logs. I also asked if you can try starting the app from the command line to see if we can isolate an issue with your Systemd config.



I’m wondering if there were any progress regarding this issue. Since I have a similar problem, however with Django==1.11.14, uWSGI==2.0.15, newrelic== multiple older versions as well with no success).

Where we run uWSGI with emperor mode.

newrelic-admin validate-config newrelic.ini posts data for me as well, but I capture no data for the web application.


Description=uWSGI Emperor



ExecStartPre=/bin/bash -c 'mkdir -p -m 1775 /run/uwsgi && chown root:app-data /run/uwsgi'
ExecStop=/bin/bash -c '/path/to/env/bin/newrelic-admin run-program /usr/local/bin/uwsgi --emperor "/path/to/vassals/configs/" --logto /var/log/uwsgi/emperor.log --stop'
ExecStart=/bin/bash -c '/path/to/env/bin/bin/newrelic-admin run-program /usr/local/bin/uwsgi --emperor "/path/to/vassals/configs/" --logto /var/log/uwsgi/emperor.log'
ExecReload=/bin/bash -c '/path/to/env/bin/bin/newrelic-admin run-program /usr/local/bin/uwsgi --emperor "/path/to/vassals/configs/" --logto /var/log/uwsgi/emperor.log --reload'


I’m aware of what is mentioned regarding uWSGI and master process

Hence (at least) these parameters can be found in uwsgi.vassal config (cropped):

master = true
processes = 4
module = django.core.wsgi:get_wsgi_application()
enable-threads = true
single-interpreter = true
lazy-apps = true

I’m still experiencing what is described regarding master process, lazy loading, etc:

If using a master process and you are seeing no data being reported for the web application running in the worker processes, you should also use lazy loading mode

Even though lazy-apps = true is set.

It shall also be said that I’m able to capture data from background tasks, but nothing regarding our web application.

Let me know if you’re interested in anything else regarding our setup.



@petter1 Could you send a permalink to your application? I want to make sure I’m looking at the same app/data you are.


@petter1 I was wondering if you could try [manual integration]( Manual integration in app code) of the Python agent. It could be possible that using emperor mode in that fashion is preventing the agent from starting in the uwsgi workers. If you are still having issues after trying that method, let me know! Could you also send me a permalink to your app?


@eileen I got it to work by not using NEW_RELIC_CONFIG_FILE and instead configure the client only through env-variables.

Although, if I remember correctly I think I attempted to initialise each worker manually (unsuccessfully) along these lines in the vassal config:

eval = import newrelic.agent; newrelic.agent.initialize('/path/to/newrelic.ini'); import django.wsgi; application = newrelic.agent.wsgi_application()(django.wsgi.application)


@petter1 Thanks for updating us with a solution that worked for you! I’m glad to hear it’s working for you now.