Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk9 min

How to Fix “No Module Named django.core.wsgi” on a VPS

A practical VPS troubleshooting guide for Django’s “No module named django.core.wsgi” error, with interpreter checks, virtualenv repairs, Gunicorn paths, and service diagnostics.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The error ModuleNotFoundError: No module named 'django.core.wsgi' almost always means the VPS service is using a Python interpreter where Django is missing, damaged, or being shadowed by a local file. It can also be the first visible line of a traceback whose later line identifies the actual project error.

Fix it by checking the exact interpreter that starts Gunicorn, uWSGI, mod_wsgi, or your system service; install the project dependencies into that environment; test the import directly; then verify the WSGI module path, settings module, and working directory. Do not rely on the python or pip used in an interactive shell unless it is the same executable used by the service.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What django.core.wsgi is and what the error means

A Django project created with django-admin startproject includes a WSGI module similar to this:

from django.core.wsgi import get_wsgi_application

application = get_wsgi_application()

The WSGI server imports that module and uses the application object to serve the Django site. The django.core.wsgi package is part of Django itself; it is not a package that should be installed separately.

Therefore, an error at that import normally points to one of four conditions:

  • The service is running a Python environment without Django installed.
  • Django is installed in a different virtual environment or Python installation.
  • The Django installation is incomplete or incompatible with the interpreter.
  • A local django.py file or django/ directory is hiding the real installed package.

If the traceback continues after the Django import, read every line. A later error such as No module named project.settings or a database configuration exception may be the problem that needs fixing after Django itself loads.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

First, identify the Python process that is actually failing

Find the command used to start the application. It may be in a systemd unit, Supervisor configuration, an Apache/mod_wsgi configuration, a container entrypoint, or a shell script. Record both the Python/Gunicorn path and the application working directory.

Systemd

Inspect the unit and any drop-in overrides rather than guessing:

systemctl cat your-django.service
systemctl status your-django.service

Look for ExecStart=, WorkingDirectory=, Environment=, and any EnvironmentFile=. An ExecStart that points to /srv/app/venv/bin/gunicorn means that virtual environment, not the system python, is the one that matters.

Supervisor and shell scripts

Inspect the configured command and its directory. A common mistake is a Gunicorn executable from one virtual environment combined with a checkout or working directory from another deployment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Apache/mod_wsgi

mod_wsgi is compiled for a particular Python installation. Installing Django into an unrelated virtual environment will not help if Apache loads a module built for a different Python version. Check the Apache module and daemon configuration, including the configured Python home and path.

Repair the environment in a controlled sequence

1. Run checks with the service interpreter

Use the exact Python executable associated with the service. If the service uses /srv/myapp/venv/bin/gunicorn, the corresponding interpreter is usually /srv/myapp/venv/bin/python. Call it directly so shell activation cannot introduce ambiguity.

cd /path/to/your/project
/path/to/venv/bin/python -m pip --version
/path/to/venv/bin/python -m pip show Django
/path/to/venv/bin/python -c 'import django; print(django.get_version(), django.__file__)'

pip show returning nothing means Django is not installed in that environment. The import command prints both the version and the file being loaded, which helps expose an unexpected global installation or a shadowing path.

2. Install the project dependencies into that same environment

From the deployed checkout, install the dependency file used by the project:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
/path/to/venv/bin/python -m pip install -r requirements.txt

If the project documents a different dependency file, use that file instead. Calling pip through the chosen interpreter is deliberate: it prevents a global pip from installing packages where the service cannot see them. In a locked-down production deployment, use the project’s pinned versions and the same Python major and minor version expected by the application.

If installation reports a broken distribution, dependency conflict, or unsupported Python version, resolve that package-level issue before changing the WSGI command. A successful command is not proof that the service uses this environment; repeat the verification with the exact executable from ExecStart or the relevant server configuration.

3. Test the failing import directly

Run the smallest possible test:

/path/to/venv/bin/python -c 'from django.core.wsgi import get_wsgi_application; print("django.core.wsgi OK")'

If this command fails, the fault is still at the Python environment or package level. If it prints django.core.wsgi OK, Django is importable and the remaining traceback must be investigated as a project configuration or path problem.

4. Look for a shadowing file or directory

Python searches entries on sys.path in order. A file named django.py or a directory named django in the project or working directory can be selected before the installed Django package.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
find /path/to/your/project -maxdepth 2 ( -name 'django.py' -o -type d -name 'django' )
/path/to/venv/bin/python -c 'import django; print(django.__file__)'
/path/to/venv/bin/python -c 'import sys; print("n".join(sys.path))'

Rename the project file or directory if it is an application module rather than the real Django package. Do not delete an intentional package without checking its contents first. The printed django.__file__ should point into the virtual environment’s site-packages directory.

Verify the generated WSGI module

Settings module

The generated WSGI file sets DJANGO_SETTINGS_MODULE to the project’s settings module, for example:

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
application = get_wsgi_application()

Replace project.settings with the actual Python package and settings module in your deployment. It is not necessarily the name of the repository, VPS directory, or Git checkout. The package containing wsgi.py must be importable from the service’s Python path.

Package layout and __init__.py

Traditional Django project packages normally contain __init__.py. If the deployment relies on a package layout that requires this file and it is absent, Python may not import the project package as expected. Compare the deployed tree with the working source checkout and confirm that the WSGI file was included in the deployment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the correct Gunicorn target and directory

Gunicorn’s target uses a Python module path followed by the WSGI callable, commonly project.wsgi:application. It does not use the absolute filesystem path to wsgi.py, and it does not use the display name of a directory unless that directory is also the Python package name.

/path/to/venv/bin/gunicorn --chdir /path/to/project project.wsgi:application

--chdir makes the project directory importable before Gunicorn loads the target. You can instead set the service’s WorkingDirectory to that directory, provided the resulting Python path is correct.

Minimal systemd pattern

Adapt the paths, user, package name, and settings module to your application:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
[Unit]
Description=Django Gunicorn service
After=network.target

[Service]
User=appuser
Group=appuser
WorkingDirectory=/srv/myproject
Environment=DJANGO_SETTINGS_MODULE=project.settings
ExecStart=/srv/myproject/venv/bin/gunicorn --workers 3 --bind 127.0.0.1:8000 project.wsgi:application
Restart=on-failure

[Install]
WantedBy=multi-user.target

The important properties for this import problem are the virtual environment in ExecStart, the working directory, the module target, and the settings environment variable. Worker count, bind address, and service names are deployment choices rather than universal values.

Check the target before restarting the service

From the same working directory and with the same interpreter, test the project module:

cd /srv/myproject
/srv/myproject/venv/bin/python -c 'import project.wsgi; print(project.wsgi.application)'
/srv/myproject/venv/bin/gunicorn --check-config project.wsgi:application

The first command verifies Python’s project import. The second asks Gunicorn to validate its configuration without starting a long-running server. If your Gunicorn version or setup does not support the check command, run a short foreground start and stop it after the import result is visible.

Restart correctly and read the complete traceback

After changing a unit or environment, reload systemd’s configuration and restart the service:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo systemctl daemon-reload
sudo systemctl restart your-django.service
sudo systemctl status your-django.service
sudo journalctl -u your-django.service -n 100 --no-pager

Read the complete traceback, not only the first line displayed by a monitoring panel. A change from No module named django.core.wsgi to No module named project is useful evidence: Django is now installed and importable, while the project directory or module target is still wrong. A change to No module named project.settings points to the settings module name, package path, or DJANGO_SETTINGS_MODULE.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common failure patterns and their fixes

Symptom Likely cause What to check
pip install Django succeeds but the service still fails Django was installed globally or in another virtual environment Compare the service’s Python path with python -m pip show Django run through that exact interpreter.
Shell import works; Gunicorn import fails Gunicorn uses a different executable or environment Inspect ExecStart or the process command and run the direct import with its paired Python.
django.__file__ points into the project A local django.py or django/ shadows site-packages Rename the conflicting file or directory and retest.
Error changes to No module named project Working directory or Python path is wrong Use --chdir, set WorkingDirectory, or correct the module target.
Error changes to No module named project.settings DJANGO_SETTINGS_MODULE names the wrong package Match it to the package that contains settings.py.
Apache fails while Gunicorn works mod_wsgi is tied to a different Python installation Check the Python version and virtualenv configuration of the loaded mod_wsgi module.
Only one checkout fails after a deployment Gunicorn executable and working directory refer to different releases Inspect symlinks, release paths, and the service unit’s current directory.

Gunicorn, uWSGI, mod_wsgi, and ASGI: what changes in diagnosis

Django supports WSGI and ASGI deployment interfaces. The import diagnosis is similar across servers, but each server couples to Python and project paths differently.

Deployment path Interpreter and environment Module configuration Operational considerations
Gunicorn with WSGI Usually an executable inside a virtual environment Module and callable such as project.wsgi:application; environment variables can provide settings Process supervision, restart policy, bind address, and logs are normally handled by systemd, Supervisor, or another supervisor.
uWSGI with WSGI Confirm the Python plugin and virtualenv used by the uWSGI process Set the WSGI module and Python path in the uWSGI configuration Review emperor/vassal or service configuration, reload behavior, and the full uWSGI log.
Apache with mod_wsgi mod_wsgi is built for a specific Python installation Configure the daemon process, WSGI script, Python home, and Python path consistently Apache’s loaded module may not see packages installed by a separate system Python or virtualenv.
ASGI server Use the interpreter containing Django and the ASGI server Target the project’s ASGI callable, commonly project.asgi:application, rather than the WSGI callable Choose ASGI only when the application and server requirements call for it; the same environment and module-path checks still apply.

Switching servers is not a substitute for fixing the environment. First prove that the service interpreter can import Django and the project module; then adjust server-specific process and concurrency settings.

When the import succeeds but the site still does not start

Settings and environment variables

Check that the service receives the same required environment variables as the shell session, including DJANGO_SETTINGS_MODULE, database credentials, allowed-host settings, and secret configuration. A shell profile is not automatically loaded by systemd or Supervisor.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Working directory and relative paths

Relative paths for templates, static files, SQLite databases, certificates, or uploaded media can resolve differently under a service. Prefer paths derived from the project settings and verify the service’s working directory explicitly.

Static files and database access

Once imports work, run the project’s normal management checks and deployment preparation, such as migrations and static-file collection, using the same virtual environment. Confirm that the service account can read the code and write only where the application requires it.

Production checks after fixing the import

Do not treat a successful WSGI import as a complete production deployment. Before exposing the VPS, complete Django’s deployment checklist and review the security settings for the actual domain and infrastructure.

  • Run Django’s deployment checks with production settings.
  • Set a non-debug configuration and restrict allowed hosts.
  • Use a reliable process supervisor with automatic restart and bounded logging.
  • Put the application behind the intended web server or reverse proxy and configure HTTPS.
  • Confirm database migrations, static assets, media permissions, backups, and log rotation.
  • Test a restart and a fresh boot so the service does not depend on an interactive shell.
  • Keep the WSGI or ASGI target, virtual environment, and release directory documented for future deployments.

A concise decision tree

  1. Run from django.core.wsgi import get_wsgi_application with the exact service interpreter.
  2. If it fails, install or repair Django in that environment and remove any local shadowing module.
  3. If it succeeds, import the project WSGI module directly.
  4. If the project import fails, correct the working directory, package name, __init__.py layout, or module target.
  5. If the project import succeeds but the service fails, compare its environment variables and server configuration with the successful manual command.
  6. Restart the service, then use the new traceback to address the next configuration error rather than reverting the environment fix.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.