Why does Wont Web.py allow me to start the server on port 80?

I am trying to create a website with Web.py, but I am not allowing me to open the socket on port 80, but it works on every other port.

I have a port redirected and all that, so that is not a problem.

python main.py 80 

but when I do this, I get an error:

 http://0.0.0.0:80/ Traceback (most recent call last): File "main.py", line 43, in <module> app.run() File "/usr/local/lib/python2.7/dist-packages/web/application.py", line 311, in run return wsgi.runwsgi(self.wsgifunc(*middleware)) File "/usr/local/lib/python2.7/dist-packages/web/wsgi.py", line 54, in runwsgi return httpserver.runsimple(func, validip(listget(sys.argv, 1, ''))) File "/usr/local/lib/python2.7/dist-packages/web/httpserver.py", line 148, in runsimple server.start() File "/usr/local/lib/python2.7/dist-packages/web/wsgiserver/__init__.py", line 1753, in start raise socket.error(msg) socket.error: No socket could be created 

My code so far:

 import MySQLdb import web import hashlib as h urls = ( '/', "index", "/register/?", "register", "/login/?", "login", "/thankyou/?", "thankyou" ) app = web.application(urls, globals()) render = web.template.render("templates/") db = web.database (dbn="mysql", user="root", pw="461408", db="realmd") class index(): def GET(self): return render.index() class register(): def GET(self): return render.register() def POST(self): i = web.input() user = h.sha1(i.username).hexdigest() pw = h.sha1(i.password).hexdigest() n = db.insert("account", username=user, password=pw) if __name__ == '__main__': app.run() 

Can anyone help?

+6
source share
5 answers

You may have something else running on port 80. Try running the command netstat -ln | grep 80 netstat -ln | grep 80 to check this out.

Alternatively, you can try telnet localhost 80 , and if the connection is rejected, this port should be clear to use.

+12
source

I successfully start the service using this command in port 80

 sudo python index.py 80 

but when I use the shortcut key (control + c) to close the service, an error will occur.

  ^CTraceback (most recent call last): File "application.py", line 206, in <module> app.run() File "/Library/Python/2.7/site-packages/web.py-0.37-py2.7.egg/web/application.py", line 313, in run return wsgi.runwsgi(self.wsgifunc(*middleware)) File "/Library/Python/2.7/site-packages/web.py-0.37-py2.7.egg/web/wsgi.py", line 54, in runwsgi return httpserver.runsimple(func, validip(listget(sys.argv, 1, ''))) File "/Library/Python/2.7/site-packages/web.py-0.37-py2.7.egg/web/httpserver.py", line 159, in runsimple server.stop() File "/Library/Python/2.7/site-packages/web.py-0.37-py2.7.egg/web/wsgiserver/__init__.py", line 1932, in stop self.requests.stop(self.shutdown_timeout) File "/Library/Python/2.7/site-packages/web.py-0.37-py2.7.egg/web/wsgiserver/__init__.py", line 1471, in stop worker.join(remaining_time) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 680, in join self.__block.release() thread.error: release unlocked lock ^C^CException KeyboardInterrupt in <module 'threading' from '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.pyc'> ignored 

When this happens, I will kill all the processes in Python ...

 killall -9 python 

he can solve the above problems, but not recommended

+6
source

Visit 127.0.0.1 in the browser. There is probably already a process using port 80, and this port is supposed to be used for http, so perhaps the easiest way to see what to use with it.

+4
source

I ran into the same issue on my RaspberryPi. To fix, I just added sudo in front of the command. Try: sudo python main.py 80

0
source

Maybe you are trying to run web.py as an unprivileged user?

to try:

 sudo python ./bin/blah.py 
0
source

Source: https://habr.com/ru/post/901402/


All Articles