Solution 1 :

Unless the browser (or whatever client you are using) is running on the same computer as the server, there is no way to directly access the server’s localhost IP from the browser. It is a loopback network interface accessible only to that computer.

If the server you are trying to connect to is listening on a network interface that is reachable from the browser, then you need to give the full hostname or IP address to the server in the URL. There is no syntax that allows you to write a relative URL that accesses the same host/ip with a different post. You could dynamically generate the URL using JavaScript and use location.hostname to fetch the hostname.

If the server you are trying to connect to doesn’t listen on such a network interface then you can’t connect to it directly from the browser. You would need to expose it somehow. For example, by changing it to listen on a different network interface or by proxying requests to it through the server that is facing the browser.

Solution 2 :

Solution: Nginx proxy pass

Credit: Pierre Inglebert

server {

    listen 80;


    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    } }

NodeJS + ExpressJS – how to point my domain name to port 3000?

Problem :

I have an Nginx server set up on my server machine. I ran my node express backend on port 3000 of server, and I was able to get my html resource (stored in my server machine as well) at

however, when I try to submit my html form, it doesnt call my server’s localhost -p 3000.

What is the address for my backend API?

I have tried http://localhost:3000/[backend route][backend route]
But none of these work.

enter image description here


Comment posted by…

Thanks Quentin. I solved my problem by proxy passing my Nginx route to my localhost. Here is a reference: