I am running a localhost service on my VPS.

When i start the service, this is what i get:

Navigate to in a browser

The problem with this is that i can't open it in my browser because it's a VPS.

I have tried running ngrok, but it says connection to localhost failed.

Is there a way i can forward it to the IP address of the same VPS the localhost is running? For example i open the browser and i enter my servers IP?

  • Can you clarify what you mean by a "localhost" service? The message you see indicates that the service is not bound to an external interface, you'll need to update it's config somehow.
    – shearn89
    Sep 23, 2021 at 10:51

4 Answers 4


Do you already tried to access the port with the IP of the VPS rather than using localhost, because some application said in the console go to localhost but listen on all interfaces.

An alternative if the service only listens on localhost and you have ssh access to the VPS you can port forward the localhost port of you VPS to your local machine.

ssh user@vpsIP -L 7443:localhost:7443

explanation of -L [LOCAL_IP:]LOCAL_PORT:DESTINATION:DESTINATION_PORT the first square brackets is optional if you want to specify where to listen on your machine, default is all interfaces


Start the web server listening on remote addresses, and access over the internet.

Read the documentation of the web server in question for how to do that. Prefer production deployment scenarios, with a known web server. Possibly insert a load balancer or other utility proxy in the middle.

Toy servers for development purposes are not hardened or performant enough for operational use. And might listen on loopback addresses only.

Get a domain name for this thing as well. Easier to issue TLS certs for a name, and also easier for humans to remember.


It is possible to arrange this through a proxy. I have a WireGuard that has the internal IP address of the participants. Let's take an example from a server that connected VPN with IP address: (internal IP address) VPN IP address:

You need to install on your vps a vpn which creates a local network. I have wireguard. Then set nginx as proxy. once installed, open a browser and enter the IP address of your vps. If the nginx greeting opens. This is good. It should work something like this: a request comes to vps, nginx processes it and sends information to the connected server via vpn (WireGuard), waits for a response and sends it back to who sent the request.

It remains to fix the config.

vpn nginx config enter code here

 server {
    client_body_timeout 5s;
    client_header_timeout 5s;
    listen       80; #port
    server_name;# domen/ip vpn

    add_header Access-Control-Allow-Origin *;
    location / {
              #limit_conn addr 3;
               limit_rate 71680k;
                 #if ($http_cookie ~* ".+" ) {
                #set $cookie_cache_bypass 1;
                proxy_read_timeout      300;
                proxy_connect_timeout   300;
                proxy_redirect          off;
                proxy_set_header        X-Forwarded-Proto https;
                proxy_set_header        Host              $http_host;
                proxy_set_header        X-Real-IP         $remote_addr;
                proxy_set_header        X-Forwarded-For   
                proxy_set_header        X-Forwarded-Ssl   on;
                proxy_set_header        X-Frame-Options   SAMEORIGIN;
                proxy_cache all;
                proxy_cache_valid 404 502 503 20m;
                proxy_cache_valid any 2h;
                proxy_cache_use_stale error timeout invalid_header updating;
                gzip on;
                gzip_disable "msie6";
                gzip_vary on;
                #gzip_proxied any;
                gzip_comp_level 5;
                gzip_min_length 2240;
                gzip_proxied expired no-cache no-store private auth;
                gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;

PS: sorry for config typos if there are any.


you could install nginx proxy manager for example.

There you can add a domain or your public ip address and forward to then you could access this host with your public ip address.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.