Running a basic IIS web server

You can control a virtual machine (VM) instance on Compute Engine like anystandard Windows server. This tutorial shows you how to deploy a simple IIS webserver so you can learn the basics of running a web server on a VM.

Before you begin

You'll need a new Windows instance with HTTP traffic allowed.

  • Follow theQuickstart instructions tocreate a new Windows instance and connect to it with RDP.

Install IIS

  1. On the Windows taskbar, in the search field, typePowerShell and thenpressEnter. If there is no search field on the taskbar, click the searchicon, typePowerShell, and then pressEnter. If neither the search fieldnor the search icon appear on the taskbar, seeHide and unhide your searchbox in Windows.

  2. In the search results, underApps, right-clickWindows PowerShell,and chooseRun as administrator.

  3. Install IIS services with the following commands:

    import-module servermanager
    add-windowsfeature web-server -includeallsubfeature
  4. Overwrite the IIS web server default web page with the following command:

    echo '<!doctype html><html><body><h1>Hello World!</h1></body></html>' > C:\inetpub\wwwroot\index.html

Test your server

Test that your instance is serving traffic on its external IP:

  1. In the Google Cloud console, go to theVM instances page.

    Go to VM instances

  2. View theHello World! page by copying the IP address from theExternalIP column and pasting it into a new browser tab. If you do not see theHelloWorld! page, follow theTroubleshooting steps.

Clean up

When you're done experimenting, follow the clean up instructions in theQuickstart to avoid incurringcharges for this instance.

Troubleshooting

Receiving aConnection Refused error

If you are seeing aConnection Refused error, it is possible that:

  • Your VM instance is not publicly accessible because your firewall rules ortags are misconfigured in one of the following ways:

    • The VM instance does not have the proper tag that allows Compute Engineto apply the appropriate firewall rules to your instance.
    • Your project does not have a firewall rule that allows traffic to theexternal IP address for your instance.
  • You are trying to access the VM using anhttps address. Check that yourURL ishttp://[EXTERNAL_IP] rather thanhttps://[EXTERNAL_IP].

To ensure that your VM instance has the correct tags:

  1. In the Google Cloud console, go to theVM instances page.

    Go to VM instances

  2. Click the name of the instance that you are trying to connect to.
  3. ClickEdit at the top of the page.
  4. Scroll down toFirewalls, and make sure theAllow HTTP traffic boxis checked. If it is not checked, check it.
  5. Save your changes. This ensures that the correct tags are added to theVM instance.

To ensure that the correct firewall rule exists:

  1. In the Google Cloud console, go to theFirewall rules page.

    Go to Firewall rules

  2. Look for a firewall rule that allows all IP ranges through tcp:80. Usually,this rule is named thedefault-allow-http rule.
  3. If a rule does not exist, create one.
    1. ClickCreate firewall rule.
    2. Enter a name for the rule, such asdefault-allow-http.
    3. UnderSource IP ranges, enter0.0.0.0/0 to allow traffic fromall sources.
    4. UnderProtocols and ports, checkSpecified protocols and portsand entertcp:80.
    5. Create your firewall rule.

Test your server again by going to the external IP address of the instance:

http://[EXTERNAL_IP]

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.