Telegraf MQTT input connect fails with network error: i/o timeout

Hi all,

context: I am on Ubuntu 22.04.4 LTS

I am attempting to subscribe to the following mqtt server using telegraf inputs.mqtt : mqtt://

I have verified the username and password work - I can subscribe successfully using mosquitto_sub with these credentials. However, when I run telegraf via:

telegraf --config telegraf.conf --debug

I get the following output:

2024-04-17T06:12:39Z I! Loading config: telegraf.conf
2024-04-17T06:12:39Z I! Starting Telegraf 1.30.1 brought to you by InfluxData the makers of InfluxDB
2024-04-17T06:12:39Z I! Available plugins: 233 inputs, 9 aggregators, 31 processors, 24 parsers, 60 outputs, 6 secret-stores
2024-04-17T06:12:39Z I! Loaded inputs: mqtt_consumer
2024-04-17T06:12:39Z I! Loaded aggregators:
2024-04-17T06:12:39Z I! Loaded processors:
2024-04-17T06:12:39Z I! Loaded secretstores:
2024-04-17T06:12:39Z I! Loaded outputs: influxdb_v2
2024-04-17T06:12:39Z I! Tags enabled: host=capybara
2024-04-17T06:12:39Z I! [agent] Config: Interval:20s, Quiet:false, Hostname:“capybara”, Flush Interval:10s
2024-04-17T06:12:39Z D! [agent] Initializing plugins
2024-04-17T06:12:39Z D! [agent] Connecting outputs
2024-04-17T06:12:39Z D! [agent] Attempting connection to [outputs.influxdb_v2]
2024-04-17T06:12:39Z D! [agent] Successfully connected to outputs.influxdb_v2
2024-04-17T06:12:39Z D! [agent] Starting service inputs
2024-04-17T06:13:21Z E![telegraf] Error running agent: starting input inputs.mqtt_consumer: network Error : read tcp> i/o timeout

I don’t understand what I’m doing wrong here - any tips for debugging further?


This is a networking error, which means something in your network between your system and the destination has failed. Verify DNS, your connectivity, the port, and the hostname are all correct. Also verify the protocol you should use. You mentioned mqtt://, are you sure this is correct?

Finally, in your config, you can enable trace mode to possible get even more details via client_trace = true in your mqtt_consumer config.

1 Like

@jpowers thanks for the tip about client_trace=true - very useful

I have also removed the mqtt:// from the url as no, I was not sure this is correct. However, after running telegraf again with client_trace=true, it does appear that MQTT 3.1 the right protocol.

I edited my telegaf config file to include the scheme as suggested by the message

" 2024-04-18T23:15:15Z W! [inputs.mqtt_consumer] Server “” should be updated to use scheme://host:port format"

But I’m now confident the url should be "mqtt//” and, success - we appear to have successfully established a connection and are wating to receive messages!

1 Like