Skip to content

Incorrect address returned when listening to IPv6 #2994

Closed as not planned
Closed as not planned
@moyanj

Description

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When I set the host to  :: , the returned IP address (both  request.client_ip and  request.ip ) is incorrect when accessing via IPv4.
Just like this: ::ffff:127.0.0.1

Code snippet

from sanic import Sanic, response
from sanic.request import Request
app = Sanic("MyApp")

@app.route("/")
async def test(request: Request):
    return response.text(request.ip)
   
if __name__ == "__main__":
    app.run(host="::", port=8080, debug=True)

Expected Behavior

Returns the correct IPv4 address

How do you run Sanic?

As a script (app.run or Sanic.serve)

Operating System

Linux

Sanic Version

24.6.0

Additional context

No response

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions