Cannot connect websockets when target is e.g. 'ws://localhost:3050'

I am currently working on a project where I want to allow a client, e.g. a smartphone on the local network, to connect to the balena host, in this case a Raspberry Pi 3B+, run a set of commands, and close the local connection.

Using a NodeJS image, I am currently doing this using the Websocket library.

Say I want to connect through port 3000, I am perfectly able to do this when I know the local IP address obtained in the dashboard - but am not able to connect over localhost:3050.

Just being able to use localhost simplifies the process quite a bit. Any insights?

All the best, and thank you,
Rasmus