Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PermissionError: [Errno 13] Permission denied Flask.run()

I am running MacOS X with python 3. The folder and files have 755 but I have also tested it in 777 with no luck. My question is if I have the right permissions why does it not let me run without sudo. Or are my settings incorrect?

cris-mbp:ProjectFolder cris$ python3 zbo.py 
Traceback (most recent call last):
  File "zbo.py", line 9, in <module>
    app.run(host="127.0.0.1",port=81,debug=True)
  File "/usr/local/lib/python3.5/site-packages/flask/app.py", line 843, in run
    run_simple(host, port, self, **options)
  File "/usr/local/lib/python3.5/site-packages/werkzeug/serving.py", line 677, in run_simple
    s.bind((hostname, port))
PermissionError: [Errno 13] Permission denied
cris-mbp:ProjectFolder cris$ sudo python3 zbo.py 
 * Running on http://127.0.0.1:81/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger pin code: 106-133-233
like image 329
c3cris Avatar asked Jul 11 '16 03:07

c3cris


2 Answers

You're trying to run the app on a privileged port (81) - if you use a higher port such as 5000 you won't need sudo privileges.

like image 84
Matt Healy Avatar answered Sep 22 '22 06:09

Matt Healy


The "permission denied" error is occurring on the bind call; this has nothing to do with directory permissions.

You're attempting to bind to port 81 (an odd choice), which is a privileged port (one that is less than 1024). This means you need to run it as root.

like image 9
Jonathon Reinhart Avatar answered Sep 24 '22 06:09

Jonathon Reinhart