delete-tunnel (Delete a channel)

Updated at:
Copy as MD

The mgwutil delete-tunnel command deletes a channel by its ID. It supports interactive confirmation and a force delete option.

Command format

mgwutil delete-tunnel <tunnel-id> [--force]

Parameters

Parameter

Required

Description

tunnel-id

Yes

The ID of the channel to delete. Obtain this ID from the response returned when the channel was created.

--force

No

Specifies whether to force delete the channel in non-interactive mode. This option is disabled by default.

Usage examples

Interactive mode

You can run the delete command and confirm the operation when prompted. This is the default safe mode, which helps prevent accidental deletion.

mgwutil delete-tunnel  ****-***-***-***-***

After you run the command, a prompt appears asking you to confirm the deletion.

please confirm if you want to delete tunnel: (y/n) 
  • Enter n and press Enter to abort the operation. The message cancel the delete agent operation is displayed on the screen.

  • Enter y and press Enter to confirm the deletion.

Force delete (non-interactive mode)

The following example shows how to force delete a specified channel in non-interactive mode.

mgwutil delete-tunnel  ****-***-***-***-*** --force
Warning

The preceding command forces the deletion of a specified channel. This operation is irreversible. Proceed with caution.

Response

Success response

{
   "Code": "success" ,
   "StatusCode": 204,
   "LogTime": "2025-12-25 17:51:37",
   "Data":       {}
}

Error response

{
  "Code": "fail",
  "StatusCode": 409,
  "LogTime": "2026-01-16 10:08:07",
  "ErrorMsg": "SDKError:    StatusCode: 409    Code: ImportTunnelIsOccupied    Message: The import tunnel is occupied by import agent    Data: {'AccessDeniedDetail':null,'Recommend':null,'ecCode':null,'hostId':'11***9638769***5.cn-hangzhou.mgw.aliyuncs.com','requestId':'69699D87847D9E38353E99BB','statusCode':409} ",
  "ErrorCode": "ImportTunnelIsOccupied",
  "RequestId": "69699D87847D9E38353E99BB"
}

Error codes

Note
  • The error code indicates the error type. For more information, see the ErrorMsg field.

  • This error code is included in generic error codes.

Error code

Description

CancelOperation

The delete operation was canceled.

InvalidInput

The confirmation input is invalid. Enter only 'y' to confirm or 'n' to cancel.

ImportTunnelNotBelongTo

The channel belongs to another user.

ImportTunnelIsOccupied

The channel is already in use.