Search code examples
pythonportbottle

Chrome Error code: ERR_UNSAFE_PORT - Bottle hello world app not showing in browser


EDIT:

I looked at the chrome error code and it said: Error code: ERR_UNSAFE_PORT. I changed the port to 6001 and it works fine - why would that be, is 6000 generally a port you can't use for local development for some reason?

I've built the hello world app (I've called it app.py) like so:

from bottle import route, run

@route('/hello')
def hello():
    return "<h1>Hello World!</h1>"

run(host='localhost', port=6000, debug=True)

And I'm in a virtualenv setup with app.py in the same directory level as bin/, include/, and lib/ folders from the virtual environment. The file bottle.py is inside bin/ When I run python app.py, I get this output:

Bottle v0.12.3 server starting up (using WSGIRefServer())...
Listening on http://localhost:6000/
Hit Ctrl-C to quit.

But when I go to http://localhost:6000/hello I get "This website is not available" in Chrome. Have I structured my files wrong somehow? Thanks!


Solution

  • It's not your app, it's Chrome.

    From https://superuser.com/a/188012/220530:

    Right Click on Chrome shortcut >> Properties >>

    Then Append --explicitly-allowed-ports=xxx to shortcut target

    Example:

    C:\Documents and Settings\User\Local Settings\Application Data\Google\Chrome\Application\chrome.exe --explicitly-allowed-ports=6666