All Products
Search
Document Center

NAT Gateway:DeleteNatGateway

Last Updated:Aug 05, 2026

Deletes a specified Internet NAT gateway.

Operation description

DeleteNatGateway is an asynchronous operation. After you send a request, the system returns a request ID. However, the NAT gateway is not immediately deleted. The deletion task runs in the background. You can call DescribeNatGateways to query the status of the NAT gateway:

  • If the NAT gateway is in the Deleting state, the NAT gateway is being deleted. In this state, you can only perform query operations.

  • If the NAT gateway cannot be found, the NAT gateway is deleted.

Note

Deleting a NAT gateway is irreversible. Proceed with caution.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

vpc:DeleteNatGateway

delete

*NatGateway

acs:vpc:{#regionId}:{#accountId}:natgateway/{#natgatewayid}

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID of the NAT gateway.

You can call DescribeRegions to query the region ID.

cn-hangzhou

NatGatewayId

string

Yes

The instance ID of the NAT gateway that you want to delete.

ngw-bp1uewa15k4iy5770****

Force

boolean

No

Specifies whether to forcefully delete the NAT gateway. Valid values:

  • true: forcefully deletes the NAT gateway. If you set this parameter to true:

    • If the NAT gateway has SNAT rules, the system force deletes the SNAT rules.

    • If the NAT gateway has DNAT rules, the system force deletes the DNAT rules.

    • If the NAT gateway has associated elastic IP addresses (EIPs), the system automatically disassociates the EIPs.

    • If the NAT gateway has NAT service plans that are not deleted, the system force deletes the NAT service plans.

  • false (default): does not forcefully delete the NAT gateway. If you set this parameter to false:

    • If the NAT gateway has NAT service plans that are not deleted, delete the NAT service plans first.

    • If the NAT gateway has SNAT rules, delete the SNAT rules first.

    • If the NAT gateway has DNAT rules, delete the DNAT rules first.

    • If the NAT gateway has associated EIPs, disassociate the EIPs first.

false

Response elements

Element

Type

Description

Example

object

The request ID.

RequestId

string

The request ID.

0ED8D006-F706-4D23-88ED-E11ED28DCAC0

Examples

Success response

JSON format

{
  "RequestId": "0ED8D006-F706-4D23-88ED-E11ED28DCAC0"
}

Error codes

HTTP status code

Error code

Error message

Description

400 DependencyViolation.VpcEndpointService The specified resource of %s depends on %s, so the operation cannot be completed. You cannot perform the operation because the NAT gateway is associated with an endpoint service.
400 DependencyViolation.FullNatEntry The specified resource of %s depends on %s, so the operation cannot be completed.
400 DependencyViolation.RouterEntry The specified resource of %s depends on %s, so the operation cannot be completed. You cannot perform the operation because the NAT gateway is associated with a route entry.
400 DependencyViolation.BandwidthPackages There are BandwidthPackages on specified NatGateway not deleted.
400 DependencyViolation.EIPS There are Eips on specified NatGateway, please unbind it first. An EIP is associated with the NAT gateway. Disassociate the EIP from the NAT gateway first.
400 Forbidden.PrePaidNatGateway The specified NatGateway is PrePaid.
400 InvalidOperation.DeletionProtection The instance cannnot delete because of deletion protecion.
400 DependencyViolation.SnatEntry The specified resource of %s depends on %s, so the operation cannot be completed. The SnatEntry associated with NatIp or Ipv4Prefix cannot be deleted. Delete the dependent Snat and delete it again.
400 IncorrectStatus.SnatEntry The status of %s [%s] is incorrect.
400 DependencyViolation.ForwardEntry The specified resource of %s depends on %s, so the operation cannot be completed.
400 IncorrectStatus.ForwardEntry The status of %s [%s] is incorrect. The DNAT entry to be deleted is in an invalid state.
400 DependencyViolation.NatIp The specified resource of %s depends on %s, so the operation cannot be completed. You cannot perform the operation because the NAT gateway is associated with a NAT IP address.
400 IncorrectStatus.NatIp The status of %s [%s] is incorrect. The status of NatIp is incorrect.
400 DependencyViolation.NatIpCidr The specified resource of %s depends on %s, so the operation cannot be completed. You cannot perform the operation because the NAT gateway is associated with a NAT CIDR block.
400 IncorrectStatus.NatGateway The NatGateway instance is being deleted and needs to wait until the process is complete. The NAT Gateway instance is being deleted and cannot be repeatedly deleted. You need to wait for the deletion process to complete.
400 IncorrectStatus.RouterEntry The status of %s [%s] is incorrect. The state of the RouterEntry is incorrect.
400 IncorrectStatus.VSwitch The specified vSwitch status is invalid. The virtual switch status is abnormal.
404 INSTANCE_NOT_EXISTS Instance not exists.
404 InvalidRegionId.NotFound The specified RegionId does not exist in our records.
404 InvalidNatGatewayId.NotFound The specified NatGatewayId does not exist in our records.
404 ResourceNotFound.NatGateway The specified resource of %s is not found.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.