2

I am using the ubuntu server and want to deploy Django project in AWS using ec2, and it requires me to use port 80 to access its HTTP how do I solve this problem? I heard from other people using sudo and enabling env but this error is all I got

ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?

Please help I really need help

samtoddler
  • 8,463
  • 2
  • 26
  • 21
KIGAME KUN
  • 23
  • 1
  • 4

1 Answers1

1

The error you are getting with sudo because of the path, I am assuming you must be using virtualenv or any other tool for managing the python version and corresponding dependencies.

You can actually change the port where you default runserver

./manage.py runserver 0.0.0.0:<your_port>

django change default runserver port

The port numbers from 1 to 1023 are restricted for root user only and we can not assign those ports without having root access. If you actually want to start the server on port 80, there are some.

How to bind to port number less than 1024 with non root access?

sudo setcap CAP_NET_BIND_SERVICE=+eip /path/to/binary

OR

sudo touch /etc/authbind/byport/80
sudo chmod 777 /etc/authbind/byport/80

authbind --deep /path/to/binary command line args
samtoddler
  • 8,463
  • 2
  • 26
  • 21