Search code examples
pythonaiohttp

OSError: [Errno 10048] error while attempting to bind on address


OSError: [Errno 10048] error while attempting to bind on address ('0.0.0.0', 8080): only one usage of e
ach socket address (protocol/network address/port) is normally permitted

I have installed aiohttp and as mentioned in a tutorial, I tried to run the script using python main.py command

from aiohttp import web
async def index(request):
    return web.Response(text='Hello Aiohttp!')
app = web.Application()
web.run_app(app)

I get this error and don't know how to sort this issue.

Any kind of help is appreciated


Solution

  • From the documentation https://aiohttp.readthedocs.io/en/stable/web_reference.html#aiohttp.web.run_app .You can pass the port as

    from aiohttp import web
    async def index(request):
        return web.Response(text='Hello Aiohttp!')
    app = web.Application()
    web.run_app(app, port=9090)