Influxdb connection refused on reboot

Tags: #<Tag:0x00007fc8fa715d98> #<Tag:0x00007fc8fa715be0>
  • Platform information:

    • Hardware: Raspberry Pi 3B
    • OS: OpenHabian
    • Java Runtime Environment: Zulu8.40.0.178-CA-linux_aarch32hf (build 1.8.0_222-b178)
    • openHAB version: openHAB 2.4.0-1 (Release Build)
  • Issue of the topic:

    • TLDR; Grafana is working, but there are refused connections to influxdb in the log. Is this normal, or fixable?
    • I’ve been working to get Influx DB and Grafana working so that I can chart the values of my items. Whilst I’ve tried to follow some very good guides, my setup hasnt worked per the guides. Finally I’ve managed to draw some charts from my item data - so it appears that most of the configuration is now correct.
    • My influx db users are: admin, openhab and grafana - each with their “recommended” persmissions noted in the guides.
      • Grafana.service connects using the grafana account to http://localhost:8086.
      • Openhab connects using the openhab account to https://localhost:8086 using the persistence-influxdb - 1.13.0 add-in and the settings file (/etc/openhab2/services/influxdb.cfg)

== QUESTIONS ==

  • Is there something I’m missing, or got misconfigured?
  • Is this something that I can / should fix? or
  • Is it about boot timings of the various services?

== CONFIG FILE ==
/etc/openhab2/services/influxdb.cfg

url=http://localhost:8086
user=openhab
password=xyz
db=openhab_db
retentionPolicy=autogen

== LOGS ==
tail -f /var/log/openhab2/openhab.log /var/log/openhab2/events.log

2019-11-23 13:20:48.612 [ERROR] [.internal.InfluxDBPersistenceService] - database connection failed

retrofit.RetrofitError: Connection refused (Connection refused)

	at retrofit.RetrofitError.networkError(RetrofitError.java:27) ~[229:org.openhab.persistence.influxdb:1.13.0]

	at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:395) ~[229:org.openhab.persistence.influxdb:1.13.0]

	at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240) ~[229:org.openhab.persistence.influxdb:1.13.0]

	at org.influxdb.impl.$Proxy157.ping(Unknown Source) ~[229:org.openhab.persistence.influxdb:1.13.0]

	at org.influxdb.impl.InfluxDBImpl.ping(InfluxDBImpl.java:114) ~[229:org.openhab.persistence.influxdb:1.13.0]

	at org.openhab.persistence.influxdb.internal.InfluxDBPersistenceService.checkConnection(InfluxDBPersistenceService.java:172) [229:org.openhab.persistence.influxdb:1.13.0]

	at org.openhab.persistence.influxdb.internal.InfluxDBPersistenceService.activate(InfluxDBPersistenceService.java:145) [229:org.openhab.persistence.influxdb:1.13.0]

	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]

	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]

	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]

	at org.apache.felix.scr.impl.inject.methods.BaseMethod.invokeMethod(BaseMethod.java:228) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.inject.methods.BaseMethod.access$500(BaseMethod.java:41) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.inject.methods.BaseMethod$Resolved.invoke(BaseMethod.java:664) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.inject.methods.BaseMethod.invoke(BaseMethod.java:510) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.inject.methods.ActivateMethod.invoke(ActivateMethod.java:317) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.inject.methods.ActivateMethod.invoke(ActivateMethod.java:307) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:334) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:114) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:947) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:919) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:863) [39:org.apache.felix.scr:2.1.2]

	at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse$1.run(ServiceFactoryUse.java:212) [?:?]

	at java.security.AccessController.doPrivileged(Native Method) ~[?:?]

	at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:210) [?:?]

	at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.getService(ServiceFactoryUse.java:111) [?:?]

	at org.eclipse.osgi.internal.serviceregistry.ServiceConsumer$2.getService(ServiceConsumer.java:45) [?:?]

	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:508) [?:?]

	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.getService(ServiceRegistry.java:461) [?:?]

	at org.eclipse.osgi.internal.framework.BundleContextImpl.getService(BundleContextImpl.java:624) [?:?]

	at org.apache.felix.scr.impl.manager.SingleRefPair.getServiceObject(SingleRefPair.java:73) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.inject.BindParameters.getServiceObject(BindParameters.java:47) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.inject.methods.BindMethod.getServiceObject(BindMethod.java:662) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.DependencyManager.getServiceObject(DependencyManager.java:2304) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.DependencyManager.doInvokeBindMethod(DependencyManager.java:1801) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.DependencyManager.invokeBindMethod(DependencyManager.java:1784) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeBindMethod(SingleComponentManager.java:409) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:333) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.addedService(DependencyManager.java:302) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1216) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1137) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:944) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:880) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1168) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:125) [39:org.apache.felix.scr:2.1.2]

	at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109) [?:?]

	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:920) [?:?]

	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?]

	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [?:?]

	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862) [?:?]

	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801) [?:?]

	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127) [?:?]

	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225) [?:?]

	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:469) [?:?]

	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:891) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:877) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:128) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:944) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:727) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:661) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:427) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:665) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:339) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:381) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.Activator.access$200(Activator.java:49) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:263) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.AbstractExtender.createExtension(AbstractExtender.java:196) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:169) [39:org.apache.felix.scr:2.1.2]

	at org.apache.felix.scr.impl.AbstractExtender.modifiedBundle(AbstractExtender.java:49) [39:org.apache.felix.scr:2.1.2]

	at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482) [?:?]

	at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:415) [?:?]

	at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232) [?:?]

	at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444) [?:?]

	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:908) [?:?]

	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?]

	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [?:?]

	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:213) [?:?]

	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:120) [?:?]

	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:112) [?:?]

	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:168) [?:?]

	at org.eclipse.osgi.container.Module.publishEvent(Module.java:476) [?:?]

	at org.eclipse.osgi.container.Module.start(Module.java:467) [?:?]

	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1634) [?:?]

	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1614) [?:?]

	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1585) [?:?]

	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1528) [?:?]

	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1) [?:?]

	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [?:?]

	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340) [?:?]

Caused by: java.net.ConnectException: Connection refused (Connection refused)

	at java.net.PlainSocketImpl.socketConnect(Native Method) ~[?:?]

	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[?:?]

	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[?:?]

	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[?:?]

	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[?:?]

	at java.net.Socket.connect(Socket.java:589) ~[?:?]

	at com.squareup.okhttp.internal.Platform.connectSocket(Platform.java:100) ~[?:?]

	at com.squareup.okhttp.internal.http.SocketConnector.connectRawSocket(SocketConnector.java:160) ~[?:?]

	at com.squareup.okhttp.internal.http.SocketConnector.connectCleartext(SocketConnector.java:67) ~[?:?]

	at com.squareup.okhttp.Connection.connect(Connection.java:152) ~[?:?]

	at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:185) ~[?:?]

	at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128) ~[?:?]

	at com.squareup.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:341) ~[?:?]

	at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330) ~[?:?]

	at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248) ~[?:?]

	at com.squareup.okhttp.Call.getResponse(Call.java:273) ~[?:?]

	at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:230) ~[?:?]

	at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:201) ~[?:?]

	at com.squareup.okhttp.Call.execute(Call.java:81) ~[?:?]

	at retrofit.client.OkClient.execute(OkClient.java:53) ~[?:?]

	at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:326) ~[?:?]

	... 87 more

2019-11-23 13:20:48.730 [ERROR] [.internal.InfluxDBPersistenceService] - database connection error Connection refused (Connection refused)

2019-11-23 13:20:48.733 [ERROR] [.internal.InfluxDBPersistenceService] - database connection does not work for now, will retry to use the database.

You are using the user openhab and the password you set
The connection in refused befaore that combination is not accepted by influx

Double check the user and password. If that doesn’t work,
Log in influx as admin and reset the password for the openhab user

Thank you @vzorglub - I’ve reset the password for the openhab user and included the new value in the influx.cfg file. I’m a bit puzzled where to go next.

You didn’t mention if it is working or not…
Do you still have the same error?

The error is still there, yes sadly.
My confusion is that influx db records the openhab item data, despite the error reported on bootup.
I wonder if there’s some kind of duplication of the services (or cache?), or multiple config files that it could be reading from? As far as /etc/openhab2/ is concerned, I cant see any extra files in any of the folders (using ls -al).

Ok, then, try this
Uninstall the influx service from PaperUI
clear the cache
start openHAB
install the service again
reboot

hi,

i have the same problem than mjdyson.
But only if I really restart the complete system.
If I only restart openhab all works.
I also tried to delay the start of openhab by 2 minutes to give influx enough time to start after reboot but still the same.
Ideas?
Thanks for help

I have the same problem as well. Configuration is identical except I am using openHAB 2.5.0-1.
There is some data in influx so it was working at some point but it is a couple of days old and I am getting the same “Connection refused” error in the openhab.log every time openHAB attempts to send to influx.

Any suggestions appreciated. Thanks

Is InfluxDB running? What do you see with this?

ps -ef | grep -i influx

Hi John. I thought InfluxDB was running. It showed up in an htop list, and while troubleshooting, I had launched the InfluxDB command line and was doing queries.

Before I could try the ps command as you suggested I had decided to purge and reinstall Influx. It seems to be working fine now, even after reboot.

Thanks for the response.

Running Openhabian on Raspi 3B using an USB SSD

I have the same issue since the update to 2.5.8-1
It used to work before but now I have tons of connection refused in my log.

influx is running, so is openhab and influxdb-peristence
influxdb.persist

url=http://localhost:8086
user=openhab
password=xxx
db=openhab_db
retentionPolicy=autogen

nmap -sV -p8080-8090 localhost
results in:
8086/tcp closed d-s-n

I wonder why this is closed (never changed something)

checking the db:

drwxr-xr-x 3 influxdb influxdb 4096 Apr  2 08:09 .
drwxr-xr-x 5 influxdb influxdb 4096 Apr  2 08:09 ..
drwx------ 4 influxdb influxdb 4096 Apr  2 08:09 openhab_db
[12:16:20] openhabian@homer:/var/lib/influxdb/data$

Both the port and the permissions look odd and I wonder, if these are the reason.
More importantly how to fix these?

Any help is greatly allreciated.

I assume that was the contents of influxdb.cfg in your services file? Maybe try 127.0.0.1:8086? Can you run the influx command line query the measurements?

I’m on 2.5.8 but run my influxdb on a different virtual machine

Thank you, Nick.
I will try this.