Rizkallah
Rizkallah

Reputation: 113

Ruby on Rails - Neo4J Connection Refused

I am writing a Ruby on Rails application and using a Neo4J database. I'm using the neo4j-core gem in order to integrate the two and I have a problem when connecting to the database.

The database is not located at the same server as the application so I needed to change some configuration. In application.rb file, I added the following code:

module Workspace
  class Application < Rails::Application
    # Neo4j configuration
    config.neo4j.session_type = :server_db 
    config.neo4j.session_path = 'http://***.***.**.***:7474'
  end
end

I tried running the application after this and it was working. However, I then added the following in a controller in order to test the connection further:

module Api
    class CountriesController < ApplicationController
        def index
            Neo4j::Session.open(:server_db)

            # Get Coutnry Information
            @countryList = Neo4j::Session.query. ...
        end
    end
end

And if I try to run the application now, it's giving me the following connection error (on the line where I'm opening a Neo4J session):

connection refused: localhost:7474

Why is it trying to connect to the localhost even though in the configuration of Neo4J I specified the real IP of the database?

I'm super confused by this right now. Any help would be appreciated.

Thank you!

Upvotes: 2

Views: 337

Answers (1)

Jiř&#237; Posp&#237;šil
Jiř&#237; Posp&#237;šil

Reputation: 14402

The configuration is available in the neo4jrb/neo4j gem, not in neo4jrb/neo4j-core. Try this instead:

Neo4j::Session.open :server_db, "http://your_ip:7474"

Upvotes: 3

Related Questions