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

ECONNREFUSED on WSL2 environment #151

Closed
sHoskens opened this issue Jul 20, 2020 · 1 comment
Closed

ECONNREFUSED on WSL2 environment #151

sHoskens opened this issue Jul 20, 2020 · 1 comment

Comments

@sHoskens
Copy link

Description

I'm working on an API, running on Koa (node), and using node-jwks-rsa as the provider for koa-jwt to validate my Auth0 jwt tokens. Both Auth0 and my api have been correctly configured: I've been developing on it for a while now, and it runs correctly in several deployment configurations. However, I've recently switched from a mac to a windows laptop, and decided to give WSL2 (Windows Subsystem for Linux) a go. I've since encountered a strange issue, which seems to originate in node-jwks-rsa, and have not yet discovered any workaround.

The error log:

 jwks Requests to the JWKS endpoint available for the next minute: 4 +3s
  jwks Fetching signing key for 'SIGNING-KEY' +0ms
  jwks Fetching keys from 'my-auth0-domain/.well-known/jwks.json' +0ms
  jwks Failure: Error: connect ECONNREFUSED 127.0.0.1:80
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 80,
  config: {
    headers: {
      Accept: 'application/json, text/plain, */*',
      'User-Agent': 'axios/0.19.2'
    },
    baseURL: 'my-auth0-domain/.well-known/jwks.json',
    transformRequest: [ [Function: transformRequest] ],
    transformResponse: [ [Function: transformResponse] ],
    timeout: 30000,
    adapter: [Function: httpAdapter],
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    validateStatus: [Function: validateStatus],
    method: 'get',
    data: undefined
  },
  redacted the rest, request object seems fine

The error occurs in the getKeys function. The only thing I can think of is that the request seems to happen through port 80, yet my node server is running on 8080. Since this is the default http port, I think it's working as intended, but worth mentioning.

The issue occurs on every request to the API. I've verified that all the keys, passwords and config is correct.

Reproduction

Relevant part of app.js (config is used to inject auth0 variables, which are all correct):

import Koa from 'koa';
import jwt from 'koa-jwt';
import jwksRsa from 'jwks-rsa';

...

export default function createApp() {
  const app = new Koa();

...

  const auth0Config = config.get('auth0');
  const { domain, audience, issuer } = auth0Config;
  app.use(
      jwt({
        secret: jwksRsa.koaJwtSecret({
          cache: true,
          rateLimit: true,
          jwksRequestsPerMinute: 5,
          jwksUri: `${domain}/.well-known/jwks.json`,
        }),
        audience,
        issuer,
        algorithms: ['RS256'],
      }),
    );
  return app;
}

Environment

Node: v12.18.2
Koa: v2.11.0
koa-jwt: v4.0.0
jwks-rsa: v1.8.0

Running on:
Windows version 2004 (OS Build 20170.1000)
with Ubuntu-20.04 through WSL2

Thanks in advance for any help regarding this issue.

@sHoskens
Copy link
Author

Closing this issue, seems like it was due to a strange conflict with Docker Desktop and WSL2. Shortly after posting, curl commands started failing. Did a restart, and the Ubuntu distro was completely bugged out. A quick reinstall later and everything is running smoothly. Urgh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant