#community-help

Mac Users Unable to Connect to Typesense Health Check through BE

TLDR KARTHICK is unable to connect to Typesense health check through backend on a new Mac setup, despite configurations working on older Mac. Jason suggests checking possible issues in backend routing and environment file processing.

Powered by Struct AI
May 19, 2023 (7 months ago)
KARTHICK
Photo of md5-9885c2d5db3a85d24bc9c11809bcaf50
KARTHICK
12:58 PM
• Hi im using Mac and i have installed Typesense using Homebrew services.
brew install typesense/tap/[email protected]

• And i have started the service using
brew services start [email protected]

• I started to hit this API <http://localhost:8108/health>
• I got the status { ok: true }
• But when i try to hit the Typesense health check from my BE it's showing the below error This is happening in now before its working fine in another Mac.
Image 1 for • Hi im using Mac and i have installed Typesense using Homebrew services.
```brew install typesense/tap/typesense-server@0.24.1```
• And i have started the service using 
```brew services start typesense-server@0.24.1```
• I started to hit this API `<http://localhost:8108/health>`
• I got the status { ok: true }
• But when i try to hit the Typesense health check from my BE it's showing the below error This is happening in now before its working fine in another Mac.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:04 PM
Are you trying to connect Typensese running on your Mac from your backend?
Sergio
Photo of md5-19856b8e92142bdd0747d7a3706736c8
Sergio
04:10 PM
Where are you running the BE? You may also try 127.0.0.1 as address instead of localhost or your LAN IP. It could be related to the BE running in an isolated network (like docker)
May 21, 2023 (6 months ago)
KARTHICK
Photo of md5-9885c2d5db3a85d24bc9c11809bcaf50
KARTHICK
05:01 PM
Kishore Nallan Yes im trying this from my BE
05:03
KARTHICK
05:03 PM
Sergio No it was working in my another mac but i tried to installl this setup in new mac but im getting this issue now.
05:06
KARTHICK
05:06 PM
Kishore Nallan
• I have installed this using homebrew and started the typesense server.

• From the above health check i'm getting {ok : true}.
• When i try to connect from my BE its throwing error.
• In my older Mac its working fine i have followed the same setup procedure i'm getting error now.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:04 PM
Is your backend running on Docker or on some VM or is it running directly on your local computer?
May 22, 2023 (6 months ago)
KARTHICK
Photo of md5-9885c2d5db3a85d24bc9c11809bcaf50
KARTHICK
04:29 AM
Its running directly on my local machine. Jason
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:31 PM
Could you share the code snippet you’re using on your backend to configure the Typesense Client?
May 23, 2023 (6 months ago)
KARTHICK
Photo of md5-9885c2d5db3a85d24bc9c11809bcaf50
KARTHICK
05:35 AM
• This is the typesense config in the BE:
const configTypesense: any =
    process.env.NODE_ENV === 'development'
        ? {
              host: typesenseHost,
              port: Number(typesensePort),
              protocol: typesenseProtocol,
          }
        :
         {
              host: typesenseHost,
              protocol: typesenseProtocol,
          };

const client = new Typesense.Client({
    nodes: [configTypesense],
    apiKey:typesenseApiKey,
    connectionTimeoutSeconds: 60,
});

• This is the env:
### TYPESENSE
TYPESENSE_HOST=localhost
TYPESENSE_PORT=8108
TYPESENSE_PROTOCOL=http
TYPESENSE_APIKEY=xyz
05:38
KARTHICK
05:38 AM
• This is the Route:
typesenseRouter.get('/health/check', healthCheck);

• This is the controller:
export const healthCheck = async (
  _req: Request,
  res: Response,
  next: NextFunction
): Promise<void> => {
  try {
    const checkStatus = await typesenseHealthCheck();
    res.status(200).json({
      response: 'success',
      message: 'typesense server running successfully',
      data: checkStatus,
    });
  } catch (error) {
    next(BadRequest('Failed to run the typesense', error));
  }
};

• This is the services :
export const typesenseHealthCheck = async (): Promise<HealthResponse> => {
    const health = await client.health.retrieve();
    return health;
};

May 24, 2023 (6 months ago)
KARTHICK
Photo of md5-9885c2d5db3a85d24bc9c11809bcaf50
KARTHICK
01:17 PM
Kishore Nallan Jason Please see through this we are facing issue in our 3-4 mac
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:52 PM
It’s hard to tell where the issue is based on what you’ve shared unfortunately…
05:53
Jason
05:53 PM
If you’re able to do curl <http://localhost:8108/health> and that is successful, and you’re running your backend on your local computer, then it could be an issue with how external network calls get routed in your backend
05:54
Jason
05:54 PM
Another thing to check is make a direct HTTP call to http://localhost:8108/health instead of using ENV files and see if that works
05:54
Jason
05:54 PM
May be the env file is not being processed properly for eg

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3015 threads (79% resolved)

Join Our Community