Rebooting Instances
Rebooting also supports resizing your instance (CPU, memory, disk) while preserving its filesystem and instance ID. For a product‑oriented guide and end‑to‑end examples, see the Resizing Instances use case.
Rebooting an instance performs a graceful restart of the virtual machine, similar to restarting your computer. This is useful for applying system updates, clearing memory, or resolving temporary issues.
When to Reboot an Instance
- Apply system updates that require a restart
- Clear memory leaks or resolve performance issues
- Reset network configurations that may have become corrupted
- Recover from software hangs without losing data
- Apply configuration changes that require a system restart
Reboot an Instance
Restart a running instance gracefully:
- Python
- TypeScript
- CLI
from morphcloud.api import MorphCloudClient
client = MorphCloudClient()
instance_id = "morphvm_abc123" # Replace with your instance ID
# Get the instance and reboot it
instance = client.instances.get(instance_id=instance_id)
instance.reboot()
print(f"Instance {instance_id} is rebooting...")
print(f"Current status: {instance.status}")
import { MorphCloudClient } from 'morphcloud';
const client = new MorphCloudClient();
async function rebootInstance() {
const instance_id = "morphvm_abc123"; // Replace with your instance ID
// Get the instance and reboot it
const instance = await client.instances.get({ instance_id: instance_id });
await instance.reboot();
console.log(`Instance ${instance_id} is rebooting...`);
console.log(`Current status: ${instance.status}`);
}
rebootInstance();
# Reboot an instance
morphcloud instance reboot morphvm_abc123
Force Reboot
Perform a hard reboot when a graceful reboot doesn't work:
- Python
- TypeScript
- CLI
from morphcloud.api import MorphCloudClient
client = MorphCloudClient()
instance_id = "morphvm_abc123" # Replace with your instance ID
# Force reboot the instance
instance = client.instances.get(instance_id=instance_id)
instance.reboot(force=True)
print(f"Force rebooting instance {instance_id}...")
import { MorphCloudClient } from 'morphcloud';
const client = new MorphCloudClient();
async function forceRebootInstance() {
const instance_id = "morphvm_abc123"; // Replace with your instance ID
// Force reboot the instance
const instance = await client.instances.get({ instance_id: instance_id });
await instance.reboot({ force: true });
console.log(`Force rebooting instance ${instance_id}...`);
}
forceRebootInstance();
# Force reboot an instance
morphcloud instance reboot morphvm_abc123 --force