Why wont Web.py let me run a server on port 80?

Max00355 picture Max00355 · Nov 13, 2011 · Viewed 14.5k times · Source

Im trying to create a website with Web.py but its not letting me open a create a socket on port 80 but it works on every other port.

I have port forwarded and all that so that's not the problem.

python main.py 80

but when I do this I get the 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 is:

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 someone help please?

Answer

wim picture wim · Nov 14, 2011

You possibly have something else working on port 80. Try the command netstat -ln | grep 80 to check that.

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