r/linux4noobs • u/w0rmzuponw0rmz • 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???
7
u/ColdFreezer 4d ago
There is 0 reason to make an external server be accessible via localhost. It just sounds like you set up your networking wrong.
What program are you talking about?
4
u/Im_j3r0 4d ago
I seriously doubt an application can't accpet an IP alternative and only runs on localhost? It's just a loopback alias to 127.0.0.1 ?
But in general, tailscale is a good option for this... But since you should be able to just forward the localhost port, it is unnecessary?
Sorry for unclear advice, but I would gladly want to know what app is this?
2
u/collinalexbell 4d ago edited 4d ago
You can ssh tunnel your localhost to the remote server.
This will proxy your laptop's localhost:3000 to the server.com's localhost:4000.
2
u/TomDuhamel 4d ago
You cannot connect to
localhostremotely. End of story.The IP for
localhostis 127.0.0.1. Whatever that up that you typed is supposed to be, it's not a valid IP and is certainly notlocalhost.Your machine has an external IP and that is how you can connect to it. It you type
localhoatin your browser, it will attempt to connect to the non existent server on that very same machine — that's literally whatlocalhostmeans.1
u/kiladre 4d ago edited 4d ago
With the information you have provided it sounds like you were going in the right direction with SSH. You can bind your localhost:port to remotehost:port, you can even daisy chain multiple machines. The -L is probably what you’ve been looking at. Sounds like there might be some routing issue though or an unexpected routing issue.
Also I noticed your comment about listening and running on the same port. That’s probably what is getting in your way. If you try to bind localhost:80 to remotehost:80, but remotehost:80 is already listening for regular web traffic you’re going to run into issues.
1
u/Monoyo- 4d ago
what app is this, and what exact localhost url/port does the web ui try to open? localhost is just the machine running the browser, so the port really matters for the ssh forward.
1
u/Unique_Low_1077 Newbie arch user 4d ago
Just what in world are you even trying to do dwag. Just change your app to accept an actual ip too
1
u/DaveKerk alternativeto.net 4d ago
Whatever app you're using is meant to be run on one machine.
Do yourself a favor and fix the app or find a better one.
1
u/letsmakenewaccount 3d ago
This subnet cannot be routed and always remains on the client where it is used.
Either you configure a different subnet for the software somewhere, or you put a reverse proxy in front of it.