title: socket.gethostbyname unable to find local hostname after updating to mac osx sierra
body: <p>After updating to OS Sierra, I tried running my local test suite with <code>rspec spec</code>, this immediately broke giving this stack trace:</p>
  
  <pre><code>Coverage report generated for RSpec to /Users/October/Documents/code/clients-api/coverage. 38 / 101 LOC (37.62%) covered.
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/bundler-1.13.2/lib/bundler/runtime.rb:94:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'torid'. (Bundler::GemRequireError)
  Gem Load Error is: getaddrinfo: nodename nor servname provided, or not known
  Backtrace for gem load error is:
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/torid-1.2.4/lib/torid/generator.rb:73:in `gethostbyname'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/torid-1.2.4/lib/torid/generator.rb:73:in `create_node_id'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/torid-1.2.4/lib/torid/generator.rb:79:in `&lt;class:Generator&gt;'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/torid-1.2.4/lib/torid/generator.rb:21:in `&lt;module:Torid&gt;'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/torid-1.2.4/lib/torid/generator.rb:8:in `&lt;top (required)&gt;'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/torid-1.2.4/lib/torid.rb:22:in `&lt;top (required)&gt;'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/bundler-1.13.2/lib/bundler/runtime.rb:91:in `require'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/bundler-1.13.2/lib/bundler/runtime.rb:91:in `block (2 levels) in require'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/bundler-1.13.2/lib/bundler/runtime.rb:86:in `each'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/bundler-1.13.2/lib/bundler/runtime.rb:86:in `block in require'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/bundler-1.13.2/lib/bundler/runtime.rb:75:in `each'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/bundler-1.13.2/lib/bundler/runtime.rb:75:in `require'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/bundler-1.13.2/lib/bundler.rb:106:in `require'
  /Users/October/Documents/code/clients-api/config/application.rb:16:in `&lt;top (required)&gt;'
  /Users/October/Documents/code/clients-api/config/environment.rb:2:in `require'
  /Users/October/Documents/code/clients-api/config/environment.rb:2:in `&lt;top (required)&gt;'
  /Users/October/Documents/code/clients-api/spec/spec_helper.rb:6:in `require'
  /Users/October/Documents/code/clients-api/spec/spec_helper.rb:6:in `&lt;top (required)&gt;'
  /Users/October/Documents/code/clients-api/spec/consumers/postback_notifier_consumer_spec.rb:1:in `require_relative'
  /Users/October/Documents/code/clients-api/spec/consumers/postback_notifier_consumer_spec.rb:1:in `&lt;top (required)&gt;'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226:in `load'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226:in `block in load_spec_files'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1224:in `each'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1224:in `load_spec_files'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:97:in `setup'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:85:in `run'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:70:in `run'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:38:in `invoke'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/gems/rspec-core-3.2.3/exe/rspec:4:in `&lt;top (required)&gt;'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/bin/rspec:23:in `load'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/bin/rspec:23:in `&lt;main&gt;'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/bin/ruby_executable_hooks:15:in `eval'
  /Users/October/.rvm/gems/ruby-2.3.1@clients-api/bin/ruby_executable_hooks:15:in `&lt;main&gt;'
  </code></pre>
  
  <p>I further investigated inside the <code>torid</code> gem to find the block of code that is failing: </p>
  
  <pre><code>def self.create_node_id( pid = Process.pid )
      hostname = Socket.gethostbyname( Socket.gethostname ).first
      random   = SecureRandom.hex( 16 )
      FNV.new.fnv1a_64("#{hostname}-#{pid}-#{random}")
   end
  </code></pre>
  
  <p>When I inspected it with byebug:</p>
  
  <p><code>(byebug)hostname = Socket.gethostbyname( Socket.gethostname ).first</code> </p>
  
  <p>=> <code>(byebug)SocketError Exception: getaddrinfo: nodename nor servname provided, or not known</code>
  <code>nil</code></p>
  
  <p>Also <code>gethostname</code> does return the correct hostname:</p>
  
  <p><code>(byebug)Socket.gethostname</code> </p>
  
  <p>=> <code>(byebug) "OctobersMac"</code></p>
  
  <p>At this point, I have tried re-installing <code>homebrew</code>, <code>postgres</code>, <code>xcode</code>, <code>rvm</code> and <code>ruby</code>. I also made sure that my hostname was set to OctobersMac. It gets stranger in the fact that when I check my ports for that hostname, none are open. I set it with <code>scutil --get HostName</code> and it returns correctly. I have no firewalls set up either.</p>
  
  <p>I opened two other apps and ran <code>rspec spec</code> just to be sure that it wasn't just one app. The first came back with the exact same error and the second got a different error, though I have a feeling it has something to do with the original issue:</p>
  
  <pre><code>OctobersMac:community October$ rspec spec
  "Railtie has run for Postgis!!!!"
  /Users/October/.rvm/gems/ruby-2.3.1@community/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize': could not connect to server: Connection refused (PG::ConnectionBad)
      Is the server running on host "localhost" (::1) and accepting
      TCP/IP connections on port 5432?
  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?
      from /Users/October/.rvm/gems/ruby-2.3.1@ring-community/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
      from /Users/October/.rvm/gems/ruby-2.3.1@ring-community/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
      from /Users/October/.rvm/gems/ruby-2.3.1@ring-community/gems/activerecord-4.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
      from /Users/October/.rvm/gems/ruby-2.3.1@ring-community/gems/activerecord-postgis-adapter-3.0.0/lib/active_record/connection_adapters/postgis_adapter.rb:51:in `initialize'
      from /Users/October/.rvm/gems/ruby-2.3.1@ring-community/gems/activerecord-postgis-adapter-3.0.0/lib/active_record/connection_adapters/postgis/create_connection.rb:38:in `new'
      from /Users/October/.rvm/gems/ruby-2.3.1@ring-community/gems/activerecord-postgis-adapter-3.0.0/lib/active_record/connection_adapters/postgis/create_connection.rb:38:in `postgis_connection'
      from /Users/October/.rvm/gems/ruby-2.3.1@ring-community/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
  </code></pre>
  
  <p>Does anyone have any idea what is going on here? I'm at the end of my rope and Google doesn't have much on related issues to Mac OsX Sierra. Thank you for any time you can spare towards my issue.</p>