NetworkError when attempting to fetch resource

Hello,

When I launched grist-core using Docker Compose, the following message appeared.

Something went wrong
NetworkError when attempting to fetch resource.

The network tab of the browser’s developer tools showed that it was trying to communicate to 127.0.0.1 and failing.

Looking at the HTML source, i see

window.gristConfig = {
    "homeUrl":"https://127.0.0.1/",
    "org":"docs",
    "baseDomain":"grist.example.jp",
    ...snip...

I think homeUrl is the cause, but how can I fix it?

The docker-compose.yml is as follows.

version: '3'
volumes:
  grist:

  grist:
    image: gristlabs/grist
    restart: always
    environment:
      - DEBUG=1
      - GRIST_SANDBOX_FLAVOR=gvisor
      - GRIST_DOMAIN=grist.example.jp
      - GRIST_SINGLE_ORG=docs
      - APP_DOC_INTERNAL_URL=http://localhost:8484
      - APP_DOC_URL=https://grist.example.jp
      - APP_HOME_URL=https://grist.example.jp
      - APP_STATIC_URL=https://grist.example.jp
    volumes:
      - /var/data/grist-persist:/persist
    ports:
      - "127.0.0.1:58484:8484"

Hi @Kenzo_Nakata,

For the ports setting of 127.0.0.1:58484:8484, sounds like there is a reverse proxy wrapping Grist, is that right? Can you check if it is configured to preserve the Host header? For Nginx I think this would be something like proxy_set_header Host $http_host;

For historic reasons, Grist automatically tries to adapt to the Host in a few ways:

None of them are really appropriate for a simple self-hosting setup. I’ll look into simplifying this. I think in your setup Grist mistakenly believes it is hosted at 127.0.0.1.

Hello,

Thanks for your reply.

For the ports setting of 127.0.0.1:58484:8484 , sounds like there is a reverse proxy wrapping Grist, is that right?

Yes, that’s right.

I am using Apache and have solved the problem by configuring the following.

ProxyPreserveHost On
ProxyPass        / http://127.0.0.1:58484/
ProxyPassReverse / http://127.0.0.1:58484/

RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://127.0.0.1:58484/$1" [P,L]

I was able to access it successfully. Thank you very much!

3 Likes

Dear Paul,

I ran into the same issue: Self-hosting Grist and then getting the NetworkError. I use NGINX. In this post you recommend to check if it is configured to preserve the Host header. I have found this setting. Is there something I can do to change this to make Grist run?

Some days ago I tried it with Traefik and this worked. So I guess it is some setting thing with NGINX which causes the problem.

Hope you can help me.

I think I solved it myself. When you set the ENV variable ```
APP_HOME_URL to your Grist url it works.

1 Like