- Hi im using Mac and i have installed Typesense u...
# community-help
k
• Hi im using Mac and i have installed Typesense using Homebrew services.
Copy code
brew install typesense/tap/typesense-server@0.24.1
• And i have started the service using
Copy code
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.
k
Are you trying to connect Typensese running on your Mac from your backend?
s
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)
k
@Kishore Nallan Yes im trying this from my BE
@Sergio Behrends No it was working in my another mac but i tried to installl this setup in new mac but im getting this issue now.
@Kishore Nallan • I have installed this using homebrew and started the typesense server.
Copy code
<http://localhost:8108/health>
• 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.
j
Is your backend running on Docker or on some VM or is it running directly on your local computer?
k
Its running directly on my local machine. @Jason Bosco
j
Could you share the code snippet you’re using on your backend to configure the Typesense Client?
k
• This is the typesense config in the BE:
Copy code
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:
Copy code
### TYPESENSE
TYPESENSE_HOST=localhost
TYPESENSE_PORT=8108
TYPESENSE_PROTOCOL=http
TYPESENSE_APIKEY=xyz
• This is the Route:
Copy code
typesenseRouter.get('/health/check', healthCheck);
• This is the controller:
Copy code
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 :
Copy code
export const typesenseHealthCheck = async (): Promise<HealthResponse> => {
    const health = await client.health.retrieve();
    return health;
};
@Kishore Nallan @Jason Bosco Please see through this we are facing issue in our 3-4 mac
j
It’s hard to tell where the issue is based on what you’ve shared unfortunately…
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
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
May be the env file is not being processed properly for eg