I have a service listening on port :3000. However, I would like to change that to port :8080. Unfortunately, the program that I'm running does not allow me to change the listen port.
Is there any way that I could have localhost forward port :3000 to port :8080? So when I connect externally on :8080 it will forward that traffic to :3000?
I tried the socat commnand, but it didn't seem to work.
Edit: I tried the following command (found here). It didn't display anything, but the command kept running. When I tried to open it in Firefox, it just kept loading forever, eventually getting the connection timed out error. In chrome it said that the connection was reset. I apologize if this was me not configuring the command properly, I'm not familiar with socat or networking.
socat tcp-listen:8080,reuseaddr,fork tcp:localhost:3000
Edit 2: I ran nmap on localhost (sshing into the device), scanning for all ports. For some reason, it didn't show port :3000 as open. However, when I used its public IP address rather than localhost, port :3000 showed up. I'm hosting through Linode, if anybody knows why this is happening.
Edit 3: So the port is apparently forwarding properly, because when I use the curl command (using the public IP), it gives me the correct HTML code and an HTTP 200 OK status. But when I try to open it in a browser, I get connection timed out (Firefox) or connection was reset (Chrome). So it seems to be a browser issue. I know I'm trying to connect via HTTPS on port 8080, if that has anything to do with it.
Thanks in advance!
socatshould be able to do this. Can you edit your answer to include details about what you tried withsocatand how it failed? – satwell Mar 14 '22 at 18:03socatcommand. – Blue Herring Mar 14 '22 at 18:47socatcommand you're trying should work. A connection refused error fromsocatindicates that it can't actually connect tolocalhoston port3000. So either you don't have anything listening onlocalhostport3000, orlocalhostis not resolving the way you expect. Including an example error fromsocatwould help. Also the output ofnetstat -ln | grep :3000will help diagnose whether there's anything listening for connections on port3000and at what addresses. – satwell Mar 14 '22 at 18:583000's and8080's place in the command. I put them in their proper places, and it just doesn't output anything, but the command continues to run. As for @mnme's post, I am sure there is no firewall blocking the port. I ran a test with node.js, and I could access that just fine. – Blue Herring Mar 14 '22 at 21:40curl -v http://<ip>:8080. Using curl will provide clearer debugging information than Firefox. – satwell Mar 15 '22 at 02:55curlcommand worked just fine. I got anHTTP 200 OKresponse and the correct HTML code. But when I open it in Firefox, it loads for several minutes before telling me that the connection timed out. – Blue Herring Mar 15 '22 at 12:10