No connection could be made because the target machine actively refused it


I installed influxdb through: pip install influxdb. Then I tried executing the following code in python:

import influxdb
client = influxdb.InfluxDBClient(host='localhost', port=8086)

But I came across the following error:

requests.exceptions.ConnectionError: HTTPConnectionPool(host=‘localhost’, port=8086): Max retries exceeded with url: /query?q=CREATE+DATABASE+%22exam%22 (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x000001DF4715D128>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it’,))

I tried disabling the firewall, but I still get the error. What seems to be the problem?

Hi ,
have you started the influxd ?
Is your database up and running ?
can you connect using the influx cli ?
best regards ,


No, the documentation didn’t cover that part. I figured it should start on its own. How do I do that?

In windows , you can search for the influxd.exe and start it :wink:


You are a life saver, thank you. Have a nice day.

This error is a network-related error occurred while establishing a connection to the Server. It means that the error is occurring because there is no server listening at the hostname and port you assigned. It literally means that the machine exists but that it has no services listening on the specified port .

Generally, it happens that something is preventing a connection to the port or hostname. Either there is a firewall blocking the connection or the process that is hosting the service is not listening on that specific port. This may be because it is not running at all or because it is listening on a different port. More on…no connection

thank u, it’s been a real problem for me, and i really didn’t think it might have been caused by this