Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-21-2022 06:55 AM - edited 09-21-2022 07:05 AM
Newbie problem:
I'm trying to connect to NEO4J from Django/Vagrant and I keep getting a "ConnectionRefusedError: [Errno 111] Connection refused" when I try to run neomodel_install_labels.
in my settings file I've added:
from neomodel import config
import os
DATABASES = {
'default': env.db('SNAP_DATABASE_URL'),
}
#Connect to Neo4j Database
config.DATABASE_URL = os.environ["NEO4J_BOLT_URL"]
NEOMODEL_SIGNALS = True
NEOMODEL_FORCE_TIMEZONE = False
NEOMODEL_ENCRYPTED_CONNECTION = False
NEOMODEL_MAX_CONNECTION_POOL_SIZE = 50
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=test
NEO4J_BOLT_URL="bolt://$NEO4J_USERNAME:$NEO4J_PASSWORD@localhost:7687"
In my model file:
from neomodel import (
config,
StringProperty,
StructuredNode,
RelationshipTo,
RelationshipFrom,
Relationship
)
import os
config.DATABASE_URL = os.environ["NEO4J_BOLT_URL"]
I receive the error when I try to install_labels.
vagrant@ubuntu-focal:/vagrant$ pipenv run neomodel_install_labels data_api.py data_api/models/language.py --db bolt://neo4j:test@localhost:7687
Loading .env environment variables...
Loaded data_api.py.
Loaded data_api/models/language.py.
Connecting to bolt://neo4j:test@localhost:7687
Setting up indexes and constraints...
Found language.Language
+ Creating index node_id on label Language for class language.Language
Traceback (most recent call last):
File "/home/vagrant/.local/share/virtualenvs/vagrant-gKDsaKU3/lib/python3.9/site-packages/neo4j/_async_compat/network/_bolt_socket.py", line 504, in _connect
s.connect(resolved_address)
ConnectionRefusedError: [Errno 111] Connection refused
09-21-2022 10:28 AM
hi @MAR_DEV,
Have you checked to make sure that neo4j is listening on localhost at port 7687 and not a different port or network interface? netstat -an | grep -i listen | grep 7687 would be one way to check that
09-21-2022 10:54 AM
Hello
Yes, a team member and myself both checked. It is working outside of Vagrant.
09-21-2022 10:58 AM
It's been an awful long time since I've played with vagrant... Isn't there a special IP you have to use inside of Vagrant to refer to the host box's localhost?
Edit: maybe 10.0.2.2? Found this: https://stackoverflow.com/questions/23971373/is-it-possible-to-access-a-localhost-from-a-vagrant-dev...
All the sessions of the conference are now available online