Not able to call the api on https://tech-shop-backend-production-938b.up.railway.app/
shubham-shetyanavar
FREEOP

8 months ago

Deploy logs:

Starting Container

(node:1) [MONGODB DRIVER] Warning: useNewUrlParser is a deprecated option: useNewUrlParser has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version

(Use node --trace-warnings ... to show where the warning was created)

(node:1) [MONGODB DRIVER] Warning: useUnifiedTopology is a deprecated option: useUnifiedTopology has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version

DB Connected...

Server listening at http://127.0.0.1:8080

rocket emoji e-shop running at https://tech-shop-backend-production-938b.up.railway.app

Server listening at http://10.250.24.95:8080

$10 Bounty

4 Replies

smolpaw
HOBBY

8 months ago

Hi, This could be because your application is listening on localhost so it's unreachable by railway proxy which lives outside the container.

You need to change the hostname to listen on all interfaces. What framework are you using ? I could provide you with the exact code change required.


smolpaw

Hi, This could be because your application is listening on localhost so it's unreachable by railway proxy which lives outside the container.You need to change the hostname to listen on all interfaces. What framework are you using ? I could provide you with the exact code change required.

shubham-shetyanavar
FREEOP

7 months ago

I am using nodejs with fastify


shubham-shetyanavar

I am using nodejs with fastify

smolpaw
HOBBY

7 months ago

That explains it. Fastify by default listens strictly on localhost. You need to explicitly tell it to listen on all interfaces.
Change your code to something like this, this is a snippet from one of my projects where I used fastify.

// Start the server
const start = async () => {
    try {
        await fastify.listen({ port: 8080, host: "::" });
    } catch (err) {
        fastify.log.error(err);
        process.exit(1);
    }
};

start();

smolpaw
HOBBY

7 months ago

Hey shubham, Could you take the time to try my solution ?


Loading...