'curl to OctoPrint on Raspberry Pi 4 failing with Recv failure: Connection reset by peer
Trying to set up an interface for my Octoprint server that can give me a small snippet of my print details while it's running on a separate web server, but I'm having trouble getting requests to work.
When I curl Octoprint's provided API using the local url or local IP, it works just fine:
curl http://192.168.0.10/api/printer -H "X-Api-Key: myapikey"
{"sd":{"ready":false},...
curl http://mypi.local/api/printer -H "X-Api-Key: myapikey"
{"sd":{"ready":false},...
However, when I use my public IP, I am still hitting the Pi, but immediately (not a timeout or delay) get hit with an error:
curl http://xxx.xx.xx.xxx/api/printer -H "X-Api-Key: myapikey"
SSH-2.0-OpenSSH_7.9p1 Raspbian-10+deb10u2+rpt1
curl: (56) Recv failure: Connection reset by peer
The strange part is that I can ssh into the pi using the same url with no problem.
ssh [email protected]
pi@mypi:~ $
This applies to running the curl or ssh directly from my local machine or from my webserver.
I'm assuming it's a firewall issue, but I've set up UFW and configured the opening ports to allow 22, 80, 443, and 7768 (The port the pi is running on) for my ip and yet still somehow getting that response. I've got my ports forwarded directly between the web server and my pi's ip, and am fairly confident those are working correctly, as I'm clearly hitting the pi (It's responding with it's dist info)
Am I missing some setting on the Pi to allow curl requests hitting the pi from an external ip that's forwarded to it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
