3

I want to deploy a Rails application, using Neo4jrb, to production with Capistrano. During deployment the following error shows up:

DEBUG [5a528d81] Finished in 0.057 seconds with exit status 0 (successful).
INFO [acd66fd5] Running /usr/local/bin/chruby-exec 2.3.0 -- bundle exec rake assets:precompile as deploy@46.101.153.252
DEBUG [acd66fd5] Command: cd /home/deploy/projects/larp-tool/releases/20160522103925 && ( export RAILS_ENV="production" ; /usr/local/bin/chruby-exec 2.3.0 -- bundle exec rake assets:precompile )
DEBUG [acd66fd5]    rake aborted!
DEBUG [acd66fd5]    Neo4j::Server::Resource::ServerException: Expected response code 200 Error for request http://localhost:7474/db/data/, 401
DEBUG [acd66fd5]    /home/deploy/projects/larp-tool/shared/bundle/ruby/2.3.0/gems/neo4j-core-6.1.4/lib/neo4j-server/resource.rb:37:in `handle_response_error!'
/home/deploy/projects/larp-tool/shared/bundle/ruby/2.3.0/gems/neo4j-core-6.1.4/lib/neo4j-server/resource.rb:32:in `expect_response_code!'
/home/deploy/projects/larp-tool/shared/bundle/ruby/2.3.0/gems/neo4j-core-6.1.4/lib/neo4j-server/cypher_session.rb:86:in `initialize_resource'
...

I set the following credentials in neo4.yml:

production:
  type: server_db
  url: http://username:password@localhost:7474

and also tried:

production:
  type: server_db
  url: http://localhost:7474
  username: username
  password: password

I set up this credentials with the Neo4j REST Api, and when I run curl on the server everything seems fine:

curl http://username:password@localhost:7474/db/data/

So, why is there an error during deployment?

1 Answers1

1

Both of your neo4j.yml files looks fine on to me. The 401 in the error means that the authentication isn't working. There are a few possibilities:

  • Have you set the password in Neo4j on production by logging into the web interface? Neo4j doesn't allow you to connect with the default username / password via the HTTP endpoints (which the gem uses) and so you need to change it. If you set up the database locally with the rake tasks you probably didn't hit this because they setup the server without authentication to ease this process along.
  • You could try setting the NEO4J_URL environment variable to http://username:password@localhost:7474 to see what you get
  • As a sanity check: Is your Neo4j database running on the same server as your app (otherwise localhost wouldn't make sense)?
Brian Underwood
  • 10,746
  • 1
  • 22
  • 34