POST from a Pi can't reach HA on a NAS

Hello everyone!

So I’ve been enjoying this nice project to trigger music with RFID cards.

It worked well for years but since I have moved my HA from a Raspberry to my NAS in a docker VM, I have an issue.

To make it simple, Magic card is on a rasp pi zero and when I scan a RFID card, it’s supposed to send an event through API to HA (then the automation is to be managed in HA)

But now, in the logs of Magic Cards, whenever I scan a card, I get this error message

FetchError: request to https://myduckdnsURL:8123/api/events/magic_card_scanned failed, reason: connect ETIMEDOUT 

I’ve been communicating with the creator of Magic Card who told me that it meant that the POST was not able to reach HA.
I’ve tried with Postman to trigger a POST on https://myduckdnsURL:8123/api/events/magic_card_scanned from my computer and it worked (event visible in HA).

So my question is: why does this work from my computer, why it doesn’t from the Pi?

Any leads are welcomed :slight_smile:

Thanks!

Hi,

I’ve never used magic cards so am unsure how it is set up. If you’re sure that the issue isn’t related to the magic cards config, the only things I can think of would be firewall, router related issues or home assistant rejecting this.

I see you are using a duckdns URL, do you normally scan your RFID cards from outside the network? If so maybe you haven’t changed the port forwarding on your router to forward to your NAS. I know you say it works on your laptop which is weird but still worth checking for troubleshooting.

If the port forwarding and router firewall settings are ok, I would say see it might be a firewall or network issue with your pi. SSH into it and see if you can ping the NAS.

Last thing to check, do you have a log message in home assistant when the POST request fails? I know home assistant has a trusted proxy setting in the configuration.yaml file. You would have set this up previously when setting up your duckdns URL. So maybe it is reaching home assistant but it is being rejected, check what is there as maybe the IP has changed and also check for an IP ban file in your config directory.

Hopefully this gives you some ideas, let me know when you’ve done these checks.

Thanks a lot mate for your suggestions, really appreciate it.

I’m really not super knowledgeable about “network” stuff :stuck_out_tongue:

My RasPi that holds Magic Cards in a docker is also linked to the RFID reader. It always runs at home, at the same place as my NAS.

My port forwarding is the same as usual that I have setup for duckdns to work.

I did what you said about pinging and here is what happens
If I ping myduckdnsURL, it succeeds
If I ping myduckdnsURL:8123, it says “Name or service not known”

I did the same with the direct local IP of my NAS. Without port, ping works. With port, error message.

Is there something to conclude about this?

Thanks!

Assuming the Pi is on the same network as the Nas, can you configure it to use the ip of your ha instance instead of duckduck because that will remove your firewall?

From your magic card docker container, can you ping your HA instance by name or ip? Don’t bother about the port, ping isn’t going know anything about that.

Hello. Sorry didn’t see the notification of your message.
I’ve tried with IP directly and it’s not working either. I think I have tried all combination also with SSL and verify_ssl on true/false

screen

I don’t really know how docker works, but indeed could check if this can ping HA. So I know how to ping from the pi via Putty but could you guide me to ping from Docker?

Thanks a lot

I’ve tried

docker exec -it <docker name> ping <IP / DNS>

And I got successful packet transmitted