HONO node App getting 502 on GET /health endpoint
studyhourlabs
HOBBYOP

a month ago

Hi

I have a node server , it binds to 0.0.0.0. I keep getting connection refused when I try to visit /health endpoint of my App.

The deploy logs contains REST server listening on http://localhost:8080

I do not understand what is wrong ? Also in my project settings, I cannot find Networking option on the panel.

I have read the docs and also chatted to agent, there is no luck.

Can someone point me in right direction please ?

Thanks

Solved$10 Bounty

Pinned Solution

You can find your networking settings in the image attached.

Attachments

4 Replies

Status changed to Open Railway about 1 month ago


Your server should not be listening on localhost, but instead, on 0.0.0.0.

Additionally, make sure the port your URL is bound to is the same port the application is listening to. Something I'd try as a sanity check is to hardcode your application to listen to port 3000 and your URL to be mapped to 3000 as well.


studyhourlabs
HOBBYOP

a month ago

Server host is bound to 0.0.0.0

const port = Number.parseInt(process.env.PORT ?? "3000", 10);
  console.log("PORT from env:", process.env.PORT ?? "(unset)");
  const server = serve({
    fetch: app.fetch,
    hostname: "0.0.0.0",
    port,
  });

  server.on("error", (error: NodeJS.ErrnoException) => {
    if (error.code === "EADDRINUSE") {
      console.error(
        `Port ${port} is already in use. Stop the other server or run with PORT=${
          port + 1
        } npm run server`,
      );
      process.exit(1);
    }

    console.error(error);
    process.exit(1);

You can find your networking settings in the image attached.

Attachments


studyhourlabs
HOBBYOP

a month ago

That is it, issue was here, it was pointing to 3000. I changed to 8080 and redeployed, works now.

THANK YOU so much for the screenshot.

I believe the Agent can be better, it was trying to change the port and redeploy, but I think it got confused. And I lost the control when it took over


Status changed to Open 0x5b62656e5d about 1 month ago


Status changed to Solved 0x5b62656e5d about 1 month ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...