Express Localhost address + Mobile testing

Hi,

I am getting an ERR_CONNECTION_REFUSED on my android mobile chrome when its trying to access localhost:5000 which is setup on express on glitch.

It works on desktop but from what I have read, android chrome runs in an emulator and localhost address refers to the emulator itself rather than the express server.

Do you think there is a way to configure express to take a local ip on glitch so this would work for mobiles as well?

For example,
app.listen(5000, “192.168.1.2”, () => {
console.log(‘Listening on http://localhost:5000’);
});

The call to the localhost:5000 url is on the client-side? You should be able to use your projects URL (https://dawger.glitch.me) instead.

Ah yes sorry, you’re right its executing on the client’s context =)

https://dawger.glitch.me/ is working now on desktop and mobile.

I also had to remove the port 5000 for it to work, strange…

Thanks for your help =)

1 Like