Aug. 13, 2021 1 min read
#django #aws

Running Django Commands on AWS Elastic Beanstalkļø


When hosting Django applications on AWS Elastic Beanstalk, it is often required to run commands on the server to do some maintenance tasks.


Beanstalk provisions EC2 instances that are running the web server processes. Django commands need to run in the same environment.

You might want to fix your shell first.

After connecting using SSH with

eb ssh

load the environment variables using

export $(cat /opt/elasticbeanstalk/deployment/env | xargs)

then load the Python environment using

source /var/app/venv

and finally run your Django command

python /var/app/current/manage.py runserver