Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with ports + hanami - error reported in the description of this issue #997

Closed
rubyFeedback opened this issue May 4, 2019 · 2 comments
Assignees
Labels

Comments

@rubyFeedback
Copy link

Hello Luca and others,

Sorry if this report is not great and my apologies if I will not comment/reply to it in time; I am quite chaotic.

I will try to make the bug report as useful as possible.

There actually is not much to it:

  • I started with gem install hanami. All worked fine.

  • I then went to the official documentation and did:

    hanami new bookshelf --database=postgresql

This worked too.

I cd-ed into bookshelf/ and then did:

bundle install

This also worked fine.

I then did:

bundle exec hanami server

The result was:

[2019-05-04 14:33:13] INFO WEBrick 1.4.2
[2019-05-04 14:33:13] INFO ruby 2.6.3 (2019-04-16) [x86_64-linux]
[2019-05-04 14:33:13] INFO WEBrick::HTTPServer#start: pid=22658 port=2300

From that information I inferred that I should use localhost:2300 (I knew a bit of
sinatra prior to hanami)

I visited that in my browser and got an error:

Boot Error

Something went wrong while loading /Users/x/DATA/bookshelf/config.ru
Hanami::Model::Error: PG::ConnectionBad: could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?

/Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/hanami-model-1.3.2/lib/hanami/model/configuration.rb:161:in rescue in load!' /Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/hanami-model-1.3.2/lib/hanami/model/configuration.rb:150:in load!'
/Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/hanami-model-1.3.2/lib/hanami/model.rb:80:in load!' /Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/hanami-1.3.1/lib/hanami/components/components.rb:89:in block (2 levels) in module:Components'
/Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/hanami-1.3.1/lib/hanami/components/component.rb:44:in call' /Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/hanami-1.3.1/lib/hanami/components.rb:108:in block (2 levels) in resolve'
/Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:193:in block in fetch_or_store' /Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:172:in fetch'
/Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:192:in fetch_or_store' /Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/hanami-1.3.1/lib/hanami/components.rb:106:in block in resolve'
/Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/hanami-1.3.1/lib/hanami/components.rb:105:in each' /Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/hanami-1.3.1/lib/hanami/components.rb:105:in resolve'
/Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/hanami-1.3.1/lib/hanami/components/component.rb:144:in resolve_requirements' /Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/hanami-1.3.1/lib/hanami/components/component.rb:36:in call'
/Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/hanami-1.3.1/lib/hanami/components.rb:108:in block (2 levels) in resolve' /Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:193:in block in fetch_or_store'
/Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:172:in fetch' /Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/map.rb:192:in fetch_or_store'
/Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/hanami-1.3.1/lib/hanami/components.rb:106:in block in resolve' /Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/hanami-1.3.1/lib/hanami/components.rb:105:in each'
/Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/hanami-1.3.1/lib/hanami/components.rb:105:in resolve' /Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/hanami-1.3.1/lib/hanami.rb:126:in boot'
/Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/hanami-1.3.1/lib/hanami.rb:151:in app' /Users/x/DATA/bookshelf/config.ru:3:in block in inner_app'
/Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/rack-2.0.7/lib/rack/builder.rb:55:in instance_eval' /Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/rack-2.0.7/lib/rack/builder.rb:55:in initialize'
/Users/x/DATA/bookshelf/config.ru:1:in new' /Users/x/DATA/bookshelf/config.ru:1:in inner_app'
/Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:113:in eval' /Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:113:in inner_app'
/Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:103:in assemble_app' /Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:86:in proceed_as_child'
/Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:31:in call!' /Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/shotgun-0.9.2/lib/shotgun/loader.rb:18:in call'
/Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/hanami-1.3.1/lib/hanami/assets/static.rb:49:in call' /Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/rack-2.0.7/lib/rack/lint.rb:49:in _call'
/Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/rack-2.0.7/lib/rack/lint.rb:37:in call' /Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/rack-2.0.7/lib/rack/show_exceptions.rb:23:in call'
/Programs/Ruby/2.6.3/lib/ruby/gems/2.6.0/gems/rack-2.0.7/lib/rack/handler/webrick.rb:86:in service' /Programs/Ruby/2.6.3/lib/ruby/2.6.0/webrick/httpserver.rb:140:in service'
/Programs/Ruby/2.6.3/lib/ruby/2.6.0/webrick/httpserver.rb:96:in run' /Programs/Ruby/2.6.3/lib/ruby/2.6.0/webrick/server.rb:307:in block in start_thread'

Not entirely sure what the problem is.

The bold line by hanami displayed is:

Hanami::Model::Error: PG::ConnectionBad: could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?

What is most confusing to me is ... the commandline said I should use port 2300 and
the URL I use is:

http://localhost:2300/

So I don't know why the error message reports port 5432.

Anyway I hope this is somewhat useful to you - perhaps the error message can be found in this strange port 5432 reporting, since that is not consistent with the port shown on the commandline.

Hopefully you'll be motivated with hanami - it would be nice if we could have more alternatives to rails; rails is really heavy on the mind. This was one reason why I started with sinatra, it is so much simpler to get started ... it's only lacking when one wants to do more complex things, but from a LEARNING experience, sinatra is great - hope that hanami and padrino can have a smaller learning curve, similar to sinatra, than e. g. rails.

@cllns
Copy link
Member

cllns commented May 4, 2019

Do you have Postgres running?

If you're trying to get started in a simple way, you can run the new command without --database=postgres, and it'll use SQLite instead, which won't require running any server (though it's not great for production use).

@jodosha
Copy link
Member

jodosha commented Sep 16, 2019

@rubyFeedback As @cllns said, you weren't able to connect to Postgres. You may want either to:

  1. Check if Postgres is running
  2. Adjust the URL connection string in .env.development and/or .env.test to match your local Postgres setup.

@jodosha jodosha closed this as completed Sep 16, 2019
@jodosha jodosha added invalid and removed question labels Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants