Error during the update ESOCKETTIMEDOUT registry.yarnpkg.com

Excellent. Quoted for permanence and search:

However, when I was waiting for Step 9 to complete (after running ./discourse-setup) and everything being built, it would fail with an ESOCKETTIMEDOUT error related to yarn. The last message that tries to run is [ ! -d 'node_modules' ] || su discourse -c 'yarn install --production && yarn cache clean'.

The Fix

You need to install an editor; I prefer nano so apt-get install nano does the trick. Then go to /var/discourse/templates and run: nano web.template.yml. For comparison, here is the file you cloned from github and the area of interest is around line 159. Look familiar? It’s the same command noted above before it failed. We need to add a new section above this line to increase the timeout.

  • exec: cd: $home cmd: - “su discourse -c ‘yarn config set network-timeout 600000 -g’”

Save this change then rerun ./discourse-setup and viola, completion! It will definitely take a while, especially the brotli compression step, but it will finish.