ArangoDB-Community / pyArango

Python Driver for ArangoDB with built-in validation
https://pyarango.readthedocs.io/en/latest/
Apache License 2.0
238 stars 90 forks source link

Failed to establish a new connection #184

Open ignitehub-dev opened 4 years ago

ignitehub-dev commented 4 years ago

Hey All,

I have arango running in a docker container and im trying to connect to it via my flask app but it keeps failing to connect even tho its running and i can connect to it with my browser

Heres my code that im executing in flask

`from pyArango.connection import *

conn = Connection(arangoURL='http://0.0.0.0:8529',username="root", password="spidysense") conn.createDatabase(name="tate_db") db = conn["tate_db"] collection = db.createCollection(name="users")

if name == "main": for i in range(100): doc = collection.createDocument() doc["name"] = "Tesla-%d" % i doc["number"] = i doc["species"] = "human" doc.save()`

and here is the error its giving me.

`=== Unable to establish connection, perhaps arango is not running.

Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/urllib3/connection.py", line 157, in _new_conn (self._dns_host, self.port), self.timeout, **extra_kw File "/usr/local/lib/python3.6/dist-packages/urllib3/util/connection.py", line 84, in create_connection raise err File "/usr/local/lib/python3.6/dist-packages/urllib3/util/connection.py", line 74, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 672, in urlopen chunked=chunked, File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 387, in _make_request conn.request(method, url, **httplib_request_kw) File "/usr/lib/python3.6/http/client.py", line 1254, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/lib/python3.6/http/client.py", line 1300, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/lib/python3.6/http/client.py", line 1249, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/lib/python3.6/http/client.py", line 1036, in _send_output self.send(msg) File "/usr/lib/python3.6/http/client.py", line 974, in send self.connect() File "/usr/local/lib/python3.6/dist-packages/urllib3/connection.py", line 184, in connect conn = self._new_conn() File "/usr/local/lib/python3.6/dist-packages/urllib3/connection.py", line 169, in _new_conn self, "Failed to establish a new connection: %s" % e urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f3658fda908>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 449, in send timeout=timeout File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 760, in urlopen response_kw File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 760, in urlopen response_kw File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 760, in urlopen **response_kw [Previous line repeated 2 more times] File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 720, in urlopen method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2] File "/usr/local/lib/python3.6/dist-packages/urllib3/util/retry.py", line 436, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='0.0.0.0', port=8529): Max retries exceeded with url: /_api/user/root/database (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f3658fda908>: Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "seed_dbs.py", line 8, in conn = Connection(arangoURL='http://0.0.0.0:8529',username="root", password="spidysense") File "/usr/local/lib/python3.6/dist-packages/pyArango/connection.py", line 162, in init self.reload() File "/usr/local/lib/python3.6/dist-packages/pyArango/connection.py", line 222, in reload r = self.session.get(self.getDatabasesURL()) File "/usr/local/lib/python3.6/dist-packages/pyArango/connection.py", line 52, in call ret = self.fct(*args, kwargs) File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 543, in get return self.request('GET', url, kwargs) File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 530, in request resp = self.send(prep, send_kwargs) File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 643, in send r = adapter.send(request, kwargs) File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 516, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPConnectionPool(host='0.0.0.0', port=8529): Max retries exceeded with url: /_api/user/root/database (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f3658fda908>: Failed to establish a new connection: [Errno 111] Connection refused',))`

Im stumped as this is my first time messing around with arango and there doesnt seem to be much out there on it.

Let me know if you need any other information

Boxx1483 commented 4 years ago

0.0.0.0 is not a valid ip address to connect to? the 0.0.0.0 in networking means Any address or loopback address. If the address is hosted locally (As in arango is running on your machine), connect to it with 127.0.0.1:8529

Else use the ip address of the server Arango is hosted on. If you want to access the arango instance remotely, see this topic for configuration. https://stackoverflow.com/questions/28081017/connect-arangodb-remotely