

# Static IP addresses in Lightsail
<a name="understanding-static-ip-addresses-in-amazon-lightsail"></a>

A static IP is a fixed, public IP address that you can assign and reassign to an instance or other resource. If you haven't set up a static IP address, each time you stop or restart your instance, Lightsail assigns a new public IP address.

There are no costs associated with static IP addresses when they are attached to a Lightsail instance. However, static IP addresses incur a charge when they aren't attached to an instance. For more information, see [What do Lightsail static IPv4 addresses cost?](amazon-lightsail-frequently-asked-questions-faq-billing-and-account-management.md#what-do-lightsail-static-ips-cost).

**Important**  
If you stop or restart your instance without first creating a static IP address and attaching it to your instance, you lose your IP address when your instance restarts. You should create a static IP address and attach it to your instance to ensure that your instance always has the same public IP address. For more information, see [Create a static IP address](lightsail-create-static-ip.md).

**Topics**
+ [Create a static IP address](lightsail-create-static-ip.md)
+ [Delete a static IP address](how-to-delete-static-ip.md)

# Create and attach a static IP to your Lightsail instance
<a name="lightsail-create-static-ip"></a>

The default dynamic public IP address attached to your Amazon Lightsail instance changes every time you stop and restart the instance. Create a static IP address and attach it to your instance to keep the public IP address from changing. Later, when you point a registered domain name to your instance, you don’t have to update your domain’s DNS records every time you stop and restart your instance. You can attach one static IP to an instance. For more information, see [Static IP addresses](understanding-static-ip-addresses-in-amazon-lightsail.md).

## Prerequisites
<a name="lightsail-create-static-ip-prerequisites"></a>

You need at least one dual-stack instance running in Lightsail. To create one, see [Create an instance](getting-started-with-amazon-lightsail.md).

## Create and assign a Static IP address to an instance
<a name="create-static-ip-procedure"></a>

Follow these steps to create a new static IP address and attach it to an instance in Lightsail.

1. Sign in to the Lightsail console at [https://lightsail.aws.amazon.com/](https://lightsail.aws.amazon.com/).

1. In the left navigation pane, choose **Networking**.

1. Choose **Create static IP**.

1. Select the AWS Region where you want to create your static IP.
**Note**  
Static IP addresses can only be attached to instances in the same Region.

1. Choose the Lightsail resource to which you want to attach the static IP.

1. Enter a name for your static IP.

   Resource names:
   + Must be unique within each AWS Region in your Lightsail account.
   + Must contain 2 to 255 characters.
   + Must start and end with an alphanumeric character or number.
   + Can include alphanumeric characters, numbers, periods, dashes, and underscores.

1. Choose **Create**.

   Now when you go to the home page, you see a static IP address that you can manage.  
![\[Static IP address attached to an instance\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-static-ip-attached-to-an-instance.png)

   Also, on the **Networking** tab of your instance's management page, you will see a blue pushpin next to your public IP address. This indicates that the IP address is now static.  
![\[The Networking tab of the manage instance page\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-static-ip-pushpin.png)

For more information, see [Public and private IP addresses](understanding-public-ip-and-private-ip-addresses-in-amazon-lightsail.md).

# Delete a static IP address in Lightsail
<a name="how-to-delete-static-ip"></a>

You can create up to five static IPs per AWS Region in your Amazon Lightsail account. If you delete an instance that has a static IP address attached to it, the static IP address remains in your account. If you no longer need the static IP address, you can delete it using the Lightsail console or the AWS Command Line Interface (AWS CLI). In this guide, we show you how to delete a static IP address from your Lightsail account. For more information about static IPs, see [IP addresses](understanding-public-ip-and-private-ip-addresses-in-amazon-lightsail.md).

**Important**  
Deleting a static IP will completely remove the static IP from your Lightsail account. Resources that use that static IP, such as instances, will be impacted. You will not be able to get the static IP back after you delete it.

## Delete a static IP using the Lightsail console
<a name="delete-static-ip-from-home-page-of-console"></a>

Complete the following procedure to delete a static IP using the Lightsail console.

1. Sign in to the [Lightsail console](https://lightsail.aws.amazon.com/).

1. In the left navigation pane, choose **Networking**.

1. On the **Networking** page choose the vertical ellipsis (⋮) icon next to the static IP address that you want to delete, and then choose **Delete**.  
![\[Delete a static IP in the Networking page\]](http://docs.aws.amazon.com/lightsail/latest/userguide/images/amazon-lightsail-delete-static-ip-from-manage-static-ip-menu.png)

## Delete a static IP using the AWS CLI
<a name="delete-static-ip-using-aws-cli"></a>

Complete the following procedure to delete a static IP using the AWS CLI. The command to delete a static IP from your Lightsail account is [release-static-ip](https://docs.aws.amazon.com/cli/latest/reference/lightsail/release-static-ip.html). When you create a static IP, you're actually *allocating* it. So, instead of deleting the static IP, you're actually *releasing* it.

 **Prerequisites** 

First, if you haven't already, you need to install the AWS CLI. To learn more, see [Installing the AWS Command Line Interface](http://docs.aws.amazon.com/cli/latest/userguide/installing.html). Be sure [you configure the AWS CLI](lightsail-how-to-set-up-and-configure-aws-cli.md).

You will need the name of your static IP to release it. You can get that by using the `get-static-ips` AWS CLI command.

1. Type the following command:

   ```
   aws lightsail get-static-ips
   ```

   You should see output similar to the following.

   ```
   {
       "staticIps": [
           {
               "name": "Example-StaticIP",
               "resourceType": "StaticIp",
               "attachedTo": "MyInstance",
               "arn": "arn:aws:lightsail:us-east-2:123456789101:StaticIp/5282f35e-c720-4e5a-1234-12345EXAMPLE",
               "isAttached": true,
               "ipAddress": "192.0.2.0",
               "createdAt": 1489750629.026,
               "location": {
                   "availabilityZone": "all",
                   "regionName": "us-east-2"
               }
           },
           {
               "name": "my-other-static-ip",
               "resourceType": "StaticIp",
               "arn": "arn:aws:lightsail:us-east-2:123456789101:StaticIp/f5885e14-8984-49e5-1234-12345EXAMPLE",
               "isAttached": false,
               "ipAddress": "192.0.2.2",
               "createdAt": 1483653597.815,
               "location": {
                   "availabilityZone": "all",
                   "regionName": "us-east-2"
               }
           }
       ]
   }
   ```

1. Select the **name** value of the static IP you wish to release and make a note of it so you can use it in the next step.

   For example, you can copy the value to the clipboard.

1. Type the following command.

   ```
   aws lightsail release-static-ip --static-ip-name StaticIpName
   ```

   In the command, replace *StaticIpName* with the name of your static IP.

   If successful, you should see output similar to the following.

   ```
   {
       "operations": [
           {
               "status": "Succeeded",
               "resourceType": "StaticIp",
               "isTerminal": true,
               "statusChangedAt": 1489860944.19,
               "location": {
                   "availabilityZone": "all",
                   "regionName": "us-east-2"
               },
               "operationType": "ReleaseStaticIp",
               "resourceName": "Example-StaticIP",
               "id": "92a2f0d2-eef2-4e6f-1234-12345EXAMPLE",
               "createdAt": 1489860944.19
           }
       ]
   }
   ```