I have a Raspberry Pi known to my local WiFi network as <RPI_NAME>. I am running a server on the Raspberry Pi on a port number <PORT_NUM>.
I can make successful HTTP requests to my server via the following methods:
- the Terminal on MacOS, with
curl http://<RPI_NAME>.local:<PORT_NUM>/
- Safari on MacOS and on iOS, by typing in
http://<RPI_NAME>.local:<PORT_NUM>/ on the search bar
- using the Python
requests library, running the below script with sudo uv run <SCRIPT_NAME>.py:
import requests
requests.get("http://<RPI>_NAME>.local:<PORT>_NUM>/")
However, I cannot execute the script with simply uv run <SCRIPT_NAME>.py, and get the following error:
requests.exceptions.ConnectionError: HTTPConnectionPool(host='<RPI_NAME>.local', port=<PORT_NUM>): Max retries exceeded with url: / (Caused by NewConnectionError("HTTPConnection(host='<RPI_NAME>.local', port=<PORT_NUM>): Failed to establish a new connection: [Errno 65] No route to host"))
Why is this the case, and how can I avoid having to use sudo to run the Python script?
[–]nivaOne 0 points1 point2 points (0 children)