title: Errno::ECONNREFUSED (Failed to open TCP connection to :80 - Authenticated requests fails
body: <p>After successfully running Rails 6 apps with shared Auth0 login credentials,
  I'm building my first Rails 6 + Auth0 API (<a href="https://auth0.com/blog/building-secure-apis-with-rails-6-and-auth0/" rel="nofollow noreferrer">https://auth0.com/blog/building-secure-apis-with-rails-6-and-auth0/</a>).</p>
  <p>I've created a simple server-app named 'chirps', here is the controller:</p>
  <pre><code>class ApplicationController &lt; ActionController::API
  end
  
  class SecuredController &lt; ApplicationController
      before_action :authorize_request
    
      private
    
      def authorize_request
          AuthorizationService.new(request.headers).authenticate_request!
      rescue JWT::VerificationError, JWT::DecodeError
          render json: { errors: ['Not Authenticated'] }, status: :unauthorized
      end
  end
  
  class ChirpsController &lt; SecuredController
      # Comment this for a fully private API
      skip_before_action :authorize_request, only: [:index, :show]
  
      def index
        chirps = Chirp.all
        render json: chirps
      end
    
      def show
        chirp = Chirp.find(params[:id])
        render json: chirp
      rescue ActiveRecord::RecordNotFound
        head :not_found
      end
    
      def create
        chirp = Chirp.create!(chirp_params)
        render json: chirp, status: :created
      end
    
      def destroy
        chirp = Chirp.find(params[:id])
        chirp.delete
        head :no_content
      end
    
      private
    
      def chirp_params
        params.permit(:body, :published)
      end
    end
  </code></pre>
  <p>THE PROBLEM - Authenticated requests fails:</p>
  <pre><code>curl -H “Content-Type: application/json” -H “Authorization: bearer $API_TOKEN” -d ‘{“body”:“this is my first chirp!”, “published”:true}’ -X POST http://localhost:3000/chirps
  </code></pre>
  <p>Curl response (first part of it):</p>
  <pre><code>{&quot;status&quot;:500,&quot;error&quot;:&quot;Internal Server Error&quot;,&quot;exception&quot;:&quot;#\u003cErrno::ECONNREFUSED: Failed to open TCP connection to :80 (Connection refused - connect(2) for nil port 80)\u003e&quot;,&quot;traces&quot;:{&quot;Application Trace&quot;:[{&quot;exception_object_id&quot;:16740,&quot;id&quot;:11,&quot;trace&quot;:&quot;app/lib/json_web_token.rb:19:in `jwks_hash'&quot;},{&quot;exception_object_id&quot;:16740,&quot;id&quot;:12,&quot;trace&quot;:&quot;app/lib/json_web_token.rb:14:in `block in verify'&quot;},{&quot;exception_object_id&quot;:16740,&quot;id&quot;:17,&quot;trace&quot;:&quot;app/lib/json_web_token.rb:7:in `verify'&quot;}
  </code></pre>
  <p>Rails server response:</p>
  <pre><code>Errno::ECONNREFUSED (Failed to open TCP connection to :80 (Connection refused - connect(2) for nil port 80)):
  
  app/lib/json_web_token.rb:19:in jwks_hash'** **app/lib/json_web_token.rb:14:in block in verify’
  app/lib/json_web_token.rb:7:in verify'** **app/services/authorization_service.rb:20:in verify_token’
  app/services/authorization_service.rb:8:in authenticate_request!'** **app/controllers/secured_controller.rb:7:in authorize_request’
  127.0.0.1 - - [02/Jan/2021:12:54:19 IST] “POST /chirps HTTP/1.1” 500 19247
  - -&gt; /chirps
  
  </code></pre>
  <p>My environment is Ubuntu 20.04.1 LTS under <strong>WSL2</strong>:</p>
  <pre><code>PS C:\Users\YOLA&gt; wsl -l -v
  NAME STATE VERSION
  Ubuntu Running 2
  </code></pre>
  <p>Rails Server:</p>
  <pre><code>=&gt; Booting WEBrick
  =&gt; Rails 6.0.3.4 application starting in development http://localhost:3000
  </code></pre>
  <p>I'm quite new at this so I don't fully understand why it fails.</p>
  <p>Yony</p>