Stopping and deleting your apps

Page last updated:

You can stop and delete your apps using Cloud Foundry CLI commands.

To run the commands shown here, you must first install the Cloud Foundry Command Line Interface (cf CLI). See the Cloud Foundry Command Line Interface topics for more information.

Stop and start an app

You can stop an app for many reasons. For example, stopping an app frees the memory from your quota.

To stop an app, run cf stop APP-NAME. Replace APP-NAME with the name of the app you want to stop.

Example:

$ cf stop my-example-app

Running this commands stops the app, but databases and other provisioned services still run and consume resources. Users visiting the URL of a stopped app see a 404 error message like this one:

404 Not Found: Requested route ('my-example-app.example.com') does not exist.

To start an app, run cf start APP-NAME. Replace APP-NAME with the name of the app you want to stop.

Example:

$ cf start my-example-app

Delete an app

Deleting an app is irreversible. We recommend that you run cf target before you start to confirm you are deleting the app from the correct org and space.

Many apps use services and routes. Deleting an app does not delete the services used by the app, and you must explicitly remove routes between your app and the Internet.

Delete an app with services

To delete an app with the services you provisioned for it, delete the services first.

  1. Run cf services to view all active services in the current space.

  2. Examine the list to verify which services are bound to your app. Record the name of the service instance bound to the app. If the list shows a service instance bound to any apps besides the app you want to delete, do not delete the service instance. If you delete a service instance bound to more than one app, you deletes the service instance from all of those apps.

  3. Run cf delete-service SERVICE-INSTANCE to delete the service instance. Replace SERVICE-INSTANCE with the name of the service instance bound to your app.

Example:

$ cf delete-service my-example-service-instance

Delete an app with no services

To delete an app with no services, run cf delete -r APP-NAME. Replace APP-NAME with the name of the app. The -r option instructs the cf CLI to removes routes associated with the app.

Example:

$ cf delete -r my-example-app

In cf CLI v7+, -r no longer deletes routes when the route is mapped to more than one app.

If you delete an app without the r option, you can delete the route manually.

Use the following steps to delete the route for an app manually.

  1. Run cf routes to confirm the details of the orphaned route. The cf routes command returns a list of all active routes in the current space. This list includes the space, host name, domain, path, and any bound apps or services.

  2. Find the orphaned route in the list. The orphaned route displays as a host name without an associated app.

  3. Run cf delete-route DOMAIN-NAME --hostname HOSTNAME to delete the orphaned route. Replace DOMAIN-NAME and HOSTNAME with the domain and host name of the app you deleted.

Example:

$ cf delete-route my-domain.com --hostname my-example-app

Create a pull request or raise an issue on the source for this page in GitHub