Pycharm: run a server with root privileges

Can I run django-server in Pycharm as root? I need to start the server (in debug mode) on port 80. I set the host to 0.0.0.0 and port to 80, but if I try to start it from Pycharm, I get this error:

Error: You don't have permission to access that port. 

I also tried to run this custom command:

 sudo runserver 0.0.0.0:80 

but he fails. I am using macOsX Lion, any suggestions?

+3
source share
3 answers

You can run PyCharm as root itself, and its child processes inherit root permission, or you can use port> = 1024.

If you want to run it to access port 80 while working on an unprivileged port, consider setting up some reverse proxy server on port 80, which will redirect traffic to port Django> = 1024 so that it can work without root.

I would recommend using nginx as an interface.

Also check out this question .

+8
source

Launch PyCharm from the terminal as follows:

 sudo /Applications/PyCharm.app/Contents/MacOS/pycharm 

You need to run the binary as sudo. This will allow PyCharm to run the dev server as root on port 80.

+8
source

replace 0.0.0.0 with localhost; -)

0
source

All Articles