django elastic beanstalk

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
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/ runserver