Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PermissionError: [Errno 13] Permission denied Python

Hi I am trying to create a web server with python but I am getting an error message PermissionError: [Errno 13] Permission denied

This is my code:

import os, sys 
from http.server import HTTPServer, CGIHTTPRequestHandler

webdir = '.'
port = 80

os.chdir(webdir)
srvaddr = ('', port)
srvobj = HTTPServer(srvaddr, CGIHTTPRequestHandler)
srvobj.serve_forever()
like image 519
Sebastian Avatar asked Jun 04 '13 21:06

Sebastian


1 Answers

Try changing the port to 8080. You didn't say which OS, but most UNIX derivatives will only allow root to listen on ports below 1,024 or 4,096 depending on the OS and its configuration.

like image 169
D.Shawley Avatar answered Sep 21 '22 12:09

D.Shawley