How to manually start and run a Unity WebGL build on localhost with IIS

One of the problems many developers have with Unity’s WebGL builds is they can only run them on localhost after issuing the ‘Build & Run’ command from the editor.

This command takes a while to rebuild your entire project, which only then opens a browser tab pointing to a local build.

If you don’t want to rebuild your project each time, this handy guide will show you how to setup IIS on your local PC, and configure it correctly to run your Unity WebGL local build.

Step 1 : Enable Internet Information Services (IIS) on your PC

The first thing you need to do is add the Windows IIS Feature.

To do so, press the Windows Key on your keyboard then type in Turn windows and select the Turn Windows Features on or off in the menu that appears.

In the dialog that appears, find the Internet Information Services option and make sure it is checked, then click Ok

Step 2 : Add a site for your WebGL build in IIS

Once IIS installed, press the Windows Key on your keyboard, and type in Internet Information and select Internet Information Services (IIS) Manager from the menu that appears.

When the IIS management console opens, right-click on the Sites object in the tree, and select Add Website

Add a new website with the following options, you can name it whatever you want, make sure to set the physical path to the folder where your WebGL build index.htm file is sitting.

Set the port to 8099, or another port which you are sure is not being used already on your PC by another program.

Set the hostname to localhost.

Step 3 : Enable the .mem, .data and .unityweb MIME types in your IIS config

This step is important, otherwise IIS will not know how to serve these files locally.

In File Explorer, go the folder C:\Windows\System32\inetsrv\config and open the file applicationHost.config in a text editor.

Look for the staticContent tag in the file, and add the following mimeMaps to the list of mimeMaps already under the tag…

<mimeMap fileExtension=".mem" mimeType="application/octet-stream" /> 
<mimeMap fileExtension=".data" mimeType="application/octet-stream" /> 
<mimeMap fileExtension=".unityweb" mimeType="application/octet-stream" />

Note : These MIME maps can be added to your site in IIS, but after a reset/rebuild the MIME maps will be removed, adding them to applicationHost.config prevents this.

Once that's all setup, you can now go to http://localhost:8099 in your browser, or whichever port you assigned to the site, and all should be working!

If this helped you out, make sure to check out SuperTrucks Offroad 2, the latest version of our top-down racing game inspired by the arcade classic, Ironman Super Offroad!