Forums

Webapp is giving WSGI error "ValueError: source code string cannot contain null bytes"

When I recently checked my django app I see the errors below in the error logs

2023-03-06 08:04:22,408: Error running WSGI application
2023-03-06 08:04:22,449: ValueError: source code string cannot contain null bytes
2023-03-06 08:04:22,450:   File "/var/www/meitheal-carbontracking_pythonanywhere_com_wsgi.py", line 22, in <module>
2023-03-06 08:04:22,450:     application = get_wsgi_application()

Any pointers on where to start looking ? This seems like the like the app itself is not starting. I haven't touched the /var/www/meitheal-carbontracking_pythonanywhere_com_wsgi.py file since it's creation, when the app was working.

In that ..wsgi.py file my understanding is that it sets the project home

project_home = '/home/carbontracking/meitheal'

and then points to the settings.py file with

os.environ['DJANGO_SETTINGS_MODULE'] = 'meitheal.settings'

and then kicks off the app.

This setting file, in my case , should be /home/carbontracking/meitheal/meitheal/settings.py , is that correct ?

Best regards / Colm

That looks like one of the strings in your INSTALLED_APPS settings has a null byte in it.