Windows 11, localhost / 127.0.0.1 호출 시 포트 번호 변경

Windows 11, localhost / 127.0.0.1 호출 시 포트 번호 변경

127.0.0.1:8000에서 실행되는 Windows 11에서 fastapi http 서버를 테스트하고 있습니다. 다른 터미널에서는 127.0.0.1:8000의 서버로 요청이 전송됩니다. 결과는 잘못된 요청이며 서버는 127.0.0.1:50340에서 발생했다고 말합니다. 포트 번호가 8000에서 50340으로 변경되었습니다. 쿼리를 다시 실행하면 포트가 다시 다른 번호로 변경됩니다. 세부정보는 출력에 나와 있습니다.

서버 출력은 다음과 같습니다.

INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [2368] using StatReload
{"event":"logger initialized","level":"info","timestamp":"2023-02-17T14:53:00.373918"}
{"event":"logger initialized","level":"info","timestamp":"2023-02-17T14:53:00.592613"}
INFO:     Started server process [24260]
INFO:     Waiting for application startup.
INFO:     Application startup complete.

클라이언트 출력은 다음과 같습니다.

DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1:8000
send: b'POST /api/query HTTP/1.1\r\nHost: 127.0.0.1:8000\r\nUser-Agent: python-requests/2.28.2\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nContent-Length: 160\r\nContent-Type: application/json\r\n\r\n'
send: b'{"request_type": "query", "query_items": ["196313", "9223372032559872706", "262946", "9223372032559842189"], "number_of_predictions": 10, "include_score": true}'
reply: 'HTTP/1.1 404 Not Found\r\n'
header: date: Fri, 17 Feb 2023 14:54:23 GMT
header: server: uvicorn
header: content-length: 76
header: content-type: application/problem+json
DEBUG:urllib3.connectionpool:http://127.0.0.1:8000 "POST /api/query HTTP/1.1" 404 76

클라이언트 요청 후 서버 출력은 다음과 같습니다.

INFO:     127.0.0.1:50340 - "POST /api/query HTTP/1.1" 404 Not Found

테스트 127.0.0.1:8000 작동

PS C:\Windows\System32> Test-NetConnection 127.0.0.1 -p 8000
ComputerName     : 127.0.0.1
RemoteAddress    : 127.0.0.1
RemotePort       : 8000
InterfaceAlias   : Loopback Pseudo-Interface 1
SourceAddress    : 127.0.0.1
TcpTestSucceeded : True

네트워크 재설정을 수행하고 일반적인 네트워크 재설정 작업을 수행했지만 운이 없었습니다. 왜 이런 일이 일어나고 해결책이 무엇인지 아는 사람이 있습니까?

관련 정보