r/linux4noobs • • 4d ago

networking can you remotely access localhost url Specifically? not just its ip equivalent?

edit: ssh tunneling was the way to go! i don't know what i was doing wrong before but this comment worked perfectly! i know localhost is local to the machine it's on, i just needed to access the web ui from a different device. it IS possible!!

the only reason i needed it to use the localhost url is because the program i'm using relies on a separate api, and that api wasn't accepting other callback urls. i didn't make it so idk how it works. i also wanted the program running on my server so it'll be going 24/7; i turn off my main laptop (where i was using the ui) when i'm not using it. i won't leave the tunnel open when i'm not accessing the web ui ofc


i'm seeing sources that say it Should be possible, but i haven't gotten it to work at all. i'm trying to run a program on my server and access the web ui from my main windows device. the api the program uses relies on calling back to a http://localhost url and doesn't accept ip alternatives like http://192.168.1.000

when the web ui tries to refresh to that localhost url while the program is bound to something else, the browser just throws a connection error

i've tried ssh port forwarding and keep struggling with it bc it doesn't wanna listen and run the web ui on the same port? idk how it works :(

i keep looking up how to access programs as if they really were running locally and following the steps exactly still gets me nowhere

am i missing something??? surely accessing a remote thing with localhost specifically would be useful enough that there's a way to do it. some kinda forwarding thing that tells my laptop that "localhost:3000" should actually go to the pc server and then reflect back or smth. is this possible???

0 Upvotes

12 comments sorted by

View all comments

2

u/collinalexbell 4d ago edited 4d ago

You can ssh tunnel your localhost to the remote server.

ssh -N -L 3000:localhost:4000 user@server.com

This will proxy your laptop's localhost:3000 to the server.com's localhost:4000.