Why might cURL return '(56) Failure when receiving data from the peer' from API when python requests and javascript fetch() work
12:03 07 Nov 2025

I am migrating some control software written in python, running on a Raspberry Pi, to Home Assistant. I am having trouble getting a REST sensor to work. The sensor is supposed to post and receive info from a web based API.

The web API seems to work fine. I can communicate with it fine from python and from javascript running on the interface web pages. While trying to debug things I found that I couldn't use cURL to download the info from my API. cURL still seems to work fine when I use it for other purposes (using a laptop running ubuntu).

The minimal setup is an "API" running on https://eldwick.org.uk/immersion/test.php (obviously the real application does more than this)

 2, "b" => 1], ["a" => 5, "b" => 3], ["a" => 8, "b" => 10], ["a" => 12, "b" => 4]];
echo json_encode($result, JSON_NUMERIC_CHECK);
?>

It seems to work fine with this running on my laptop

import requests

headers = { 'User-Agent' : 'Homeassistant', 'Content-Type': 'application/json' }
req = requests.post("https://eldwick.org.uk/immersion/test.php", headers=headers)
print(req.json())

or from a web page https://eldwick.org.uk/immersion/test.html with



    
        
    
    
        
        

Is the cURL behavior caused by something that might make the homeassistant sensor not work?

Is there something obvious I'm missing?

python php curl home-assistant