Hey all,
I have an express api that communicates with the auth0 management api through the node-auth0 package. The express api handles users signing up to our platform and auth0 handles our user management after signup. Everything works on our production and testing environments but breaks locally with the error: Sandbox Error: connect ECONNREFUSED 127.0.0.1:8080 (this results in the user not being created in auth0)
Interestingly, our api is running on port 3000 not 8080 but it is possible we have some legacy code running on 8080. I wouldn’t know why creating a user would be looking for 8080 however. I am hoping instead the stack trace with somebody’s help can guide me better on what the above error really means.
The below is our code:
- to run our server:
yarn run dev
which runs this command in our package.jsonnodemon -e js,mustache,scss,json ./bin/www
- when somebody signs up to the platform a post request is made to an express route which carries out a number of tasks, one of which is to add a user to auth0 by calling our adddToAuth0 function. The code to do so is as follows:
const { ManagementClient, AuthenticationClient } = require('auth0');
const managementApi = new ManagementClient({
domain: process.env.AUTH0_DOMAIN,
clientId: process.env.AUTH0_CLIENT_KEY,
clientSecret: process.env.AUTH0_CLIENT_SECRET,
scope: 'read:users create:users',
});
const addToAuth0 = (email, emailVerified, name, userDetails, referralDetails) => {
const params = {
connection: 'primary',
otherData...
};
return managementApi.createUser(params);
};
- the following is the stack trace I receive:
Unhandled rejection Bad Request: Sandbox Error: connect ECONNREFUSED 127.0.0.1:8080
at **sensitive info**/node_modules/rest-facade/src/Client.js:386:27
at Request.callback (**sensitive info**/node_modules/superagent/lib/node/index.js:728:3)
at parser (**sensitive info**/node_modules/superagent/lib/node/index.js:916:18)
at Stream.res.on (**sensitive info**/node_modules/superagent/lib/node/parsers/json.js:19:7)
at Stream.emit (events.js:189:13)
at Unzip.unzip.on (**sensitive info**/node_modules/superagent/lib/node/unzip.js:55:12)
at Unzip.emit (events.js:194:15)
at endReadableNT (_stream_readable.js:1125:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
From previous event:
at **sensitive info**/node_modules/lru-memoizer/lib/async.js:124:30
at Array.forEach (<anonymous>)
at **sensitive info**/signup/node_modules/lru-memoizer/lib/async.js:120:25
at **sensitive info**/node_modules/auth0/src/management/ManagementTokenProvider.js:82:13
From previous event:
at Auth0RestClient.wrappedProvider (**sensitive info**/node_modules/auth0/src/Auth0RestClient.js:37:8)
at Auth0RestClient.create (**sensitive info**/node_modules/auth0/src/Auth0RestClient.js:62:15)
at RetryOperation._fn (**sensitive info**/node_modules/auth0/src/RetryRestClient.js:99:10)
at RetryOperation.attempt (**sensitive info**/node_modules/retry/lib/retry_operation.js:112:8)
at **sensitive info**/node_modules/auth0/src/RetryRestClient.js:97:15
From previous event:
at RetryRestClient.handleRetry (**sensitive info**/node_modules/auth0/src/RetryRestClient.js:94:17)
at RetryRestClient.invoke (**sensitive info**/node_modules/auth0/src/RetryRestClient.js:71:22)
at RetryRestClient.create (**sensitive info**/node_modules/auth0/src/RetryRestClient.js:47:20)
at UsersManager.create (**sensitive info**/signup/node_modules/auth0/src/management/UsersManager.js:179:21)
When I have placed console.logs in some of the auth0 code it seems to be calling createUser on a RetryRestClient, not sure if that is supposed to happen
Environment
- node-auth0: ^2.19.0
- Auth0 api v2