MemoryError on GeoDjango project

I’m developing a GeoDjango project on Rocky Linux 9 and deploying using Apache. The application ran fine before when I used the standard Postgres database engine: “ENGINE”: “django.db.backends.postgresql”, but as soon as I swap to the PostGIS backend engine: ‘ENGINE’: ‘django.contrib.gis.db.backends.postgis’, I get the following error:

File “/home/centurion/centurion_web/.venv/lib/python3.12/site-packages/django/contrib/gis/db/backends/postgis/”, line 7, in from .adapter import PostGISAdapter File “/home/centurion/centurion_web/.venv/lib/python3.12/site-packages/django/contrib/gis/db/backends/postgis/”, line 5, in from django.contrib.gis.geos import GEOSGeometry File “/home/centurion/centurion_web/.venv/lib/python3.12/site-packages/django/contrib/gis/geos/”, line 5, in from .collections import ( # NOQA File “/home/centurion/centurion_web/.venv/lib/python3.12/site-packages/django/contrib/gis/geos/”, line 5, in from django.contrib.gis.geos import prototypes as capi File “/home/centurion/centurion_web/.venv/lib/python3.12/site-packages/django/contrib/gis/geos/prototypes/”, line 7, in from django.contrib.gis.geos.prototypes.coordseq import ( # NOQA File “/home/centurion/centurion_web/.venv/lib/python3.12/site-packages/django/contrib/gis/geos/prototypes/”, line 3, in from django.contrib.gis.geos.libgeos import CS_PTR, GEOM_PTR, GEOSFuncFactory File “/home/centurion/centurion_web/.venv/lib/python3.12/site-packages/django/contrib/gis/geos/”, line 88, in notice_h = NOTICEFUNC(notice_h) ^^^^^^^^^^^^^^^^^^^^ MemoryError

I hadn’t even implemented any geospatial code in the application yet. I have a development server on windows that the application runs normally on with that engine using the runserver command.

I’ve tried directly setting the GEOS_LIBRARY_PATH and GDAL_LIBRARY_PATH with no success. I downgraded from django 5.0 to 4.2 with no success. I also tried upping the RAM on the droplet from 2GB to 8GB with no success.

SOLVED IT! It was an SELinux issue preventing httpd from accessing the right files.