API Server Error & Authentication Error

I am getting a few errors that I need some help with when I follow the starter docs.

The first error crops up when I get past the “Deploy” step of the tutorial and I navigate to http://localhost:8910/admin/posts

The RedwoodJS API server is not available or is currently reloading. Please refresh.

When I refresh the error does not go away…

Here is the full error that pops up in my terminal

Summary
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/graphql to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/graphql to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/graphql to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/graphql to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)
web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/graphql to http://[::1]:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)

I read through this issue which had the same error, but I am not tracking on how they fixed it


The second error is when I try to display the signed in users email. Following the tutorial here I get this error

My temp work around was to use currentUser.id and that made the error go away but then the next time I spun up a local environment I got the same error but instead of (reading 'email') it was (reading 'id')… I remember having this issue about six months or so ago but I am blanking on how I solved it. I think it had something to do with my Yarn version (which I am running 1.22.17 btw).

Hmm this seems like react is trying to render before you have the current user. One thing you could try is currentUser?.email and see if that helps with the rendering issue. Although the redwood auth provider should prevent the page from showing before it receives the currentUser

I gave currentUser?.email a try and it did not clear the error…

Hmm also its interesting that it’s highlighting the tag is your home route expecting a parameter of email?

I ran yarn rw test and got three failures. The one that may pertain to my first issue The RedwoodJS API server is not available or is currently reloading. Please refresh. is throwing this error:

Full Error
 FAIL   api  api/src/services/contacts/contacts.test.js (9.325 s)
  ● contacts › creates a contact

    EmailValidationError: Email must be formatted like an email address

      13 |
      14 | export const createContact = ({ input }) => {
    > 15 |   validate(input.email, 'email', { email: true })
         |   ^
      16 |   return db.contact.create({
      17 |     data: input,
      18 |   })

      at validationError (node_modules/@redwoodjs/api/dist/validations/validations.js:288:9)
      at Object.email (node_modules/@redwoodjs/api/dist/validations/validations.js:84:7)
      at validate (node_modules/@redwoodjs/api/dist/validations/validations.js:311:26)
      at createContact (api/src/services/contacts/contacts.js:15:3)
      at api/src/services/contacts/contacts.test.js:29:26
      at Object.<anonymous> (node_modules/@redwoodjs/testing/config/jest/api/jest.setup.js:163:22)

It seems that validate is not functioning properly and that is on the API side of Redwood… :thinking:

is your home route expecting a parameter of email?

How would I check that?

On second thought I think those test errors are to be expected (as I proceeded from the Intermission portion using my own code built from Chapters 1-4…). From the starter docs:

If you continued with your own repo from chapters 1-4, you may see some failures here: we made a lot of changes to the pages, components and cells we generated, but didn’t update the tests to reflect the changes we made.

Yeah that error seems to be saying that input.email does not looks like test@email.com

I’ve run into this same issue and it’s not clear how it should be resolved. I didn’t want to create a new thread, so here it goes.

The project ran fine yesterday. I’m able to build and serve the project but when I run yarn rw dev I get the following in the console:

web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/auth?method=getToken to http://localhost:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors) web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/graphql to http://localhost:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors) web | <e> [webpack-dev-server] [HPM] Error occurred while proxying request localhost:8910/graphql to http://localhost:8911/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)

When I navigate to http://localhost:8910/.redwood/functions/

I get the following:

{"errors":[{"message":"The RedwoodJS API server is not available or is currently reloading. Please refresh."}]}

What happens if you go to http://localhost:8911/graphql ?

Scroll back through your terminal output where you ran yarn rw dev it sounds like the api server is erroring out and not starting. You should see the error message near the top. So even though the web side is running, and api side isn’t, and you see that message.

For background on 8910 vs 8911: 8910 is the web server, 8911 is the api server. Going to /.redwood/functions on 8910 is really just a proxy for going directly to 8911.

There is no exception thrown after yarn rw dev.

I get a ton of the following:

api | (node:78514) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time

api | (Use node --trace-warnings ... to show where the warning was created)
api | Building… Took 601 ms
api | Debugger listening on ws://127.0.0.1:18911/d72dd39d-cce5-4357-a627-6f232a85559d
api | For help, see: Debugging - Getting Started | Node.js
api | [addDir]
api | Building… Took 168 ms
api | Debugger listening on ws://127.0.0.1:18911/7c527f43-c623-45ad-8710-cf74dd362a54
api | For help, see: Debugging - Getting Started | Node.js
api | [addDir]
api | Building… Took 191 ms

It appears something is stopping the API from starting properly. I’m not able to navigate to the provided API link.

That ‘[addDir]’ line jumps out to me as it keeps running these lines until I stop the process.

Any thoughts?

Hmm, I haven’t seen that before. Any idea @dthyresson ?

I have not seen that — the addDir — either.

What OS and version of RedwoodJS are you using?

@sykespro It has been a hot minute since I dealt with this error. So, I cannot be 100% sure if this is how I cleared it or not but if you check out this thread I had an issue with yarn rw dev back in RW 0.37 that I resolved by running the following:

yarn --force then re-ran yarn rw dev and the same error I first reported popped up again…

So, I ran git clean -fdx -e .env then yarn install

This cleared up a different error message when running yarn rw dev and I honestly cannot remember if I did this to clear up this error message I experienced in May and that you are now experiencing… but at the very least it may be worth a shot. :crossed_fingers: :crossed_fingers: :crossed_fingers:

1 Like

This helped me with this error!
It seemed to pop up for me as I got Vercel Serverless functions working, but I was also adding Pre-rendering to some pages so not really sure when yarn rw dev stopped functioning correctly.
Testing webhooks is hard haha so I was mostly deploying to production to see how things were actually coming through live.
After a week or so as I came back to some front-end, yarn rw dev gave the error described here:
The RedwoodJS API server is not available or is currently reloading. Please refresh. error across graphQL items.

Redwood 3.2
MacOS Monterey 12.6 on MBP M1 Pro

1 Like