Unable to access Frappe 14 site on Local Network (VirtualBox)

what does: bench restart return, in the vm?

webserver is running on 8000 …

curl localhost:8000

curl localhost:8000
image

bench restart
image

Ok, please show your nginx.conf file … /yourbench/config/nginx.conf

nginx.cong file contents:

upstream frappe-bench-frappe {
        server 127.0.0.1:8000 fail_timeout=0;
}

upstream frappe-bench-socketio-server {
        server 127.0.0.1:9000 fail_timeout=0;
}



# setup maps


# server blocks

server {

        listen 80;
        listen [::]:80;


        server_name
                workdone
                ;

        root /home/workdone/frappe-bench/sites;



        proxy_buffer_size 128k;
        proxy_buffers 4 256k;
        proxy_busy_buffers_size 256k;



        add_header X-Frame-Options "SAMEORIGIN";
        add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
        add_header X-Content-Type-Options nosniff;
        add_header X-XSS-Protection "1; mode=block";
        add_header Referrer-Policy "same-origin, strict-origin-when-cross-origin";

        location /assets {
                try_files $uri =404;
        }

        location ~ ^/protected/(.*) {
                internal;
                try_files /$host/$1 =404;
        }

        location /socket.io {
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_set_header X-Frappe-Site-Name $host;
                proxy_set_header Origin $scheme://$http_host;
                proxy_set_header Host $host;

                proxy_pass http://frappe-bench-socketio-server;
        }

        location / {

                rewrite ^(.+)/$ $1 permanent;
                rewrite ^(.+)/index\.html$ $1 permanent;
                rewrite ^(.+)\.html$ $1 permanent;

                location ~* ^/files/.*.(htm|html|svg|xml) {
                        add_header Content-disposition "attachment";
                        try_files /$host/public/$uri @webserver;
                }

                try_files /$host/public/$uri @webserver;
        }

        location @webserver {
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Frappe-Site-Name $host;
                proxy_set_header Host $host;
                proxy_set_header X-Use-X-Accel-Redirect True;
                proxy_read_timeout 120;
                proxy_redirect off;

                proxy_pass  http://frappe-bench-frappe;
        }

        # error pages
        error_page 502 /502.html;
        location /502.html {
                root /usr/local/lib/python3.10/dist-packages/bench/config/templates;
                internal;
        }

        # optimizations
        sendfile on;
        keepalive_timeout 15;
        client_max_body_size 50m;
        client_body_buffer_size 16K;
        client_header_buffer_size 1k;

        # enable gzip compresion
        # based on https://mattstauffer.co/blog/enabling-gzip-on-nginx-servers-including-laravel-forge
        gzip on;
        gzip_http_version 1.1;
        gzip_comp_level 5;
        gzip_min_length 256;
        gzip_proxied any;
        gzip_vary on;
        gzip_types
                application/atom+xml
                application/javascript
                application/json
                application/rss+xml
                application/vnd.ms-fontobject
                application/x-font-ttf
                application/font-woff
                application/x-web-app-manifest+json
                application/xhtml+xml
                application/xml
                font/opentype
                image/svg+xml
                image/x-icon
                text/css
                text/plain
                text/x-component
                ;
                # text/html is always compressed by HttpGzipModule
}

Tried to create a new site, just for testing?

@vimalraj

Watch this video

ERPNext Error After Install - 127.0.0.1 does not exist

I hope this works

Thank You!

I tried the method shown in this video already. It did not work.

I created a new site called “test” using:
bench new-site test

Then I added it to “/etc/hosts” file using:
bench --site test add-to-hosts

Then I added it to “currentsite.txt” using:
bench use test

Then I setup and reload Nginx and Supervisor using the following:

bench setup nginx
bench setup supervisor
sudo service nginx reload
sudo service supervisor restart

Then I restarted the bench using:
bench restart

Then I rebooted the whole Server(VM) using:
sudo reboot

It still did not work. The site is still showing 404.

If I understand the mechanism correctly:

if you use
bench --site test add-to-hosts
then you should access the site with the URL
http://test:8000

(or whatever port your webserver is on)
This assumes that you’re using the browser on the same machine where your erpnext instance is running.

If I got it correctly, ERPNext seems to use virtual hosts in order to differentiate between sites, so the sitename must be provided by the browser (which is the normal procedure), but if the name of the site is not available via DNS (for instance if you have the erpnext instance on a machine in the internet WITH exactly that site name as DNS name), then the machine you browse with to your test site must use the site name as domain name (in the http:// expression) AND use the IP of your test instance. If you use another machine to browse your test instance, you should make sure that the /etc/hosts file of your broswer machine contains the IP address of your erpnext instance where the site is running. Which could be another IP on your LAN, or the IP of your virtual box host. So these things depend somewhat on your local/LAN setup. On windows the hosts file has another path, but can also be used as such a DNS shortcut.

You mean replace the default ip 127.0.0.1 with ip of the Virtual box ( Something like: 192.168.1.36 ). This is how the “/etc/hosts” file look like in my Virtual box can you say what change should be done to make it work:
image

Yes. But:

What is the IP of the machine with the browser?
Is it Linux, Windows, OpenBSD, mac, …?

You should change the /etc/hosts NOT in the virtualhost machine, but the hosts file of the machine you use to browse to the erpnext instance.

1 Like

I think is 192.168.1.36 (based on previous screenshares)

In your HOST PC hosts file, add

192.168.1.36 workdone

In recent windows os, hosts file is here C:\Windows\System32\drivers\etc\hosts
(open with save permissions …)

Try now acces to workdone from the browser on your HOST PC …

Should I add the IP and site name in both host and client? In that case how to add it in windows file? Should I just add it at the end without “#”?

Add it in client PC.
Don’t use # (is used for comments) . Just add a line

192.168.1.36 workdone

And save it.

It should be:
192.168.1.36 test

(e.g. the name of the site which you created with bench and which is active)

You can add several site names with the same IP to your windows hosts file. That’s not a problem.

I added ‘192.168.1.38 workdone’ (IP changed to 38) in the last line of hosts file in windows and added the same in ‘/etc/hosts’ in linux. Still not working.

And then you opened the URL http://workdone:8000 in your windows browser?

And does the ERPNext instance in your virtualbox have a site “workdone” (created with bench)?
Or does it have a different name?

Yes there is a site called workdone. The current site is set to ‘workdone’. When I try to access site using workdone:8002: