(BUG) Unity Web GL build preview only works once

Im currently debugging my gamejam for ludumdare, when i click build and run (webgl build) it open on chrome normally, but if you build and run again it say :
This site can’t be reached
localhost refused to connect.

If i close unity and open the project again it will build and display normally but a second, third try it wont make it work.

Notes:

I create a bran new projects (no scripts) just the default scene and still getting the same bug.

1 Like

My suggestion for a work around is to make a simple script that calls BuildPipeline.BuildPlayer and then runs Chrome with the specified flag to open the index.html file. Or just build to the same directory and run a local http server to view the game in Chrome (I recommend MiniWeb for Windows).

However, seems like Unity does not host the server after second build & run - you should report it as a bug.

Did you ever report this? I’m running into the same issue suddenly. I’ve never had this problem and haven’t changed anything in my files or chrome.

I was able to download the project from collaborate on another computer and build and run worked perfectly on that machine. On my original computer I tried redownloading the collab version, still can’t build and run more than once. Tried uninstalling and reinstalling Unity and still can’t build and run more than once. I’ve also restarted my computer but at this point sounds like a computer/driver/corruption issue somewhere between Unity and this local server it creates to test WebGL.

Just create simple server on node js + express to serve public files and then drop your build in public folder

I get your suggestion but this doesn’t explain why the same version same everything suddenly stops working with build and run. I had this working on a different computer and it just started doing this to me again. I has worked for a long time so there is clearly some error or change in the builds or cache that is causing this. I need to know how Unity is creating this server to run these and why suddenly it won’t let build and run like it is supposed to.