Ethan Leonard
Ethan Leonard

Reputation: 245

curl connection refused with thingsboard HTTP API

Details:

I am trying to post telemetry to thingsboard using the following command, as in the HTTP API Guide:

curl -v -X POST -d "{\"temperature\": 25}" 122.20.192.14/api/v1/Ll6Pfoi5MosB5bC4nUxb/telemetry --header "Content-Type:application/json"

The ip address is the address of my virtual machine running Ubuntu 20.04, with Thingsboard services running and demo data loaded on premise as per the Installation Guide.I am submitting the curl command from my windows bash environment, and I get the following error:

 curl(7) Failed to connect to 122.20.192.14 port 80 after 2044 ms: Connection refused

I am able to run the equivalent command (with http://localhost:8080 replacing the ip address of course) from my virtual machine's terminal without error.

I have tried using ss -anp | grep LISTEN | grep :80, and it tells me something like this:

tcp LISTEN 0 100 *:8080 *:* (I don't know how to copy paste from my vm, but absent the formatting it's the response it gave me)

I think this means it is listening on that port, so why is the connection refused?

I've looked at similar posts regarding both sending data through HTTP to Thingsboard and curl error(7), but haven't been able to resolve this issue.

(Note that I have randomly edited the ip address and device access token from their true values so they aren't publicly available, so if you identify a problem with those specific sequences, that's probably not the issue.)

Upvotes: 0

Views: 422

Answers (1)

Can you check the firewall? It might happen because the firewall has not allowed port 80. Try sudo ufw allow 80 and sudo ufw reload. Please do tell me what happens afterwards.

Upvotes: 0

Related Questions