# Error "Service not found" when trying to authenticate user using auth0 in React app with Express.js backend

**URL:** <https://community.auth0.com/t/error-service-not-found-when-trying-to-authenticate-user-using-auth0-in-react-app-with-express-js-backend/113351>\
**Category:** Get Help\
**Tags:** sdks-quickstarts, auth0-react\
**Created:** [August 10, 2023, 12:23pm UTC](https://community.auth0.com/t/error-service-not-found-when-trying-to-authenticate-user-using-auth0-in-react-app-with-express-js-backend/113351 "2023-08-10T12:23:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![santhoshprabhakaran0](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/santhoshprabhakaran0/32/48816_2.png) [@santhoshprabhakaran0](https://community.auth0.com/u/santhoshprabhakaran0)\
**Post date:** [August 10, 2023, 12:23pm UTC](https://community.auth0.com/t/error-service-not-found-when-trying-to-authenticate-user-using-auth0-in-react-app-with-express-js-backend/113351/1 "2023-08-10T12:23:32Z")

</div>

0

I’m currently working on a React application with an Express.js backend where I’m trying to authenticate users using the Auth0 package. I have a setup where the frontend and backend communicate through API requests.

In my React app, I’m encountering an error: “Service not found: [http://localhost:5000](http://localhost:5000)” when trying to make a request from the frontend to the backend after obtaining an access token. I’ve checked the configurations and URLs, but I can’t seem to pinpoint the issue.

Here’s the relevant code:

Frontend: I’m using the useMutation hook to make the API request after obtaining the access token.

```auto
const { mutate } = useMutation({
  mutationKey: [user?.email],
  mutationFn: async (token) => {
    try {
      await ApiInstance.post(
        Endpoints.createUser,
        {
          email: user?.email,
        },
        {
          headers: {
            Authorization: `Bearer ${token}`,
          },
        }
      );
    } catch (error) {
      console.error("An error occurred:", error);
      throw error;
    }
  },
});

```

Backend: I’m using the express-oauth2-jwt-bearer package to perform JWT token validation.

```auto
import { auth } from "express-oauth2-jwt-bearer";

export const jwtCheck = auth({
  audience: "http://localhost:5000",
  issuerBaseURL: "https://MY_DOMAIN.auth0.com",
  tokenSigningAlg: "RS256",
});

```

I’ve verified that the URLs, CORS configuration, and token audience match on both the frontend and backend. The Express.js server is running on [http://localhost:5000](http://localhost:5000).

What could be causing this “Service not found” error? Are there any common pitfalls or misconfigurations I should be aware of when setting up this type of authentication flow between a React app and an Express.js backend?

Any help or insights would be greatly appreciated. Thank you!

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [August 14, 2023, 3:42pm UTC](https://community.auth0.com/t/error-service-not-found-when-trying-to-authenticate-user-using-auth0-in-react-app-with-express-js-backend/113351/3 "2023-08-14T15:42:35Z")

</div>

Hi @santhoshprabhakaran0,

Welcome to the Auth0 Community!

Thanks for the thorough question.

The service not found error indicates that the service for which you are requesting a token (`http://localhost:5000`) hasn’t been registered with Auth0. Have you set up an _API_ in the Auth0 dashboard and set the correct identifier?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [August 29, 2023, 1:06pm UTC](https://community.auth0.com/t/error-service-not-found-when-trying-to-authenticate-user-using-auth0-in-react-app-with-express-js-backend/113351/4 "2023-08-29T13:06:26Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
