Skip to content

Port number changes in access logs #4018

@jbrownkramer

Description

@jbrownkramer

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the FastAPI documentation, with the integrated search.
  • I already searched in Google "How to X in FastAPI" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to FastAPI but to Pydantic.
  • I already checked if it is not related to FastAPI but to Swagger UI.
  • I already checked if it is not related to FastAPI but to ReDoc.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
def read_root():
    return {"Hello": "World"}

# Call the api once every 50 to 100 ms.

Description

I start a fastapi server on a port. I can access the server on that port, but the access logs show a changing port number for each request. What is happening there?

For example, I started a server on port 0 and it starts on port 55646. Initially accesses to this server are reported as port 55646, but eventually it starts reporting 55653. Note that I continue to access the server on port 55646.

2021-10-07 15:57:26,460 - uvicorn.access - INFO - 127.0.0.1:55646 - "GET /get_result?frame_number=5732305 HTTP/1.1" 200
2021-10-07 15:57:26,463 - uvicorn.access - INFO - 127.0.0.1:55646 - "POST /processframe_async?shape=(512,512)&dtype=uint16&frame_number=5732309 HTTP/1.1" 200
2021-10-07 15:57:39,911 - uvicorn.access - INFO - 127.0.0.1:55653 - "GET /get_result?frame_number=5732309 HTTP/1.1" 200
2021-10-07 15:57:39,917 - uvicorn.access - INFO - 127.0.0.1:55653 - "POST /processframe_async?shape=(512,512)&dtype=uint16&frame_number=5732313 HTTP/1.1" 200

I have seen situations where this port number increments on every call. Is uvicorn somehow truly using these ports? Do I have to worry about it trying to use a pre-existing port?

Operating System

Windows

Operating System Details

Windows 10.

FastAPI Version

0.65.2

Python Version

Python 3.8.10

Additional Context

No addition context.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions