General tips for using Compute Engine Stay organized with collections Save and categorize content based on your preferences.
This page describes tips that you might find helpful if you run into problemsusing Compute Engine.
For help troubleshooting specific issues, see one of the following sections:
- For steps to troubleshoot general issues with instances, such as if yourinstance doesn't start up, seeGeneral troubleshooting.
- For steps to troubleshoot issues with Windows instances, seeTroubleshooting Windows instances.
Viewing different response formats
The Google Cloud CLI performs most of its actions by making RESTAPI calls. The pretty-printed results show only the most important informationreturned by any specific command. To see the different response formats,use the--format flag which displays the response in different output formats,includingjson,yaml, andtext. For example, to see a list of instances inJSON, use--format json:
gcloud compute instances list --format jsonViewing gcloud compute logs
The gcloud CLI creates and stores logs in a log file that youcan query, located at$HOME/.config/gcloud/logs. To see the latest log file ona Linux-based operating system, run:
$less $(find ~/.config/gcloud/logs | sort | tail -n 1)The log file includes information about all requests and responses made usingthegcloud CLI tool.
To automatically purge the log files created by the gcloud CLI,use themax_log_days property,which sets the maximum number of days to retain log files before deleting.The default setting is 30 days. If you set this property value to 0, it turnsoff log garbage collection and does not delete log files.
gcloud config set core/max_log_daysDAYS_TO_RETAIN_LOGS
Disable gcloud CLI file logging:
The file$HOME/.config/gcloud/logs consumes space on the local filesystem.The amount of logs generated might overwhelm the amount of space on the localfilesystem, which can cause issues like:
- Space utilization reaching 100% on the instance.
- Failure to execute gcloud CLI logging commands because there isno space left to create a new file on the local filesystem.
To change the gcloud CLI behavior and disable the filelogging, use thedisable_file_loggingproperty:
gcloud config set core/disable_file_logging True
disable_file_logging property. To check the gcloud version, use the commandgcloud -v.Selecting resource names
When selecting names for your resources, keep in mind that these friendly-namesmay be visible on support and operational dashboards within Compute Engine.For this reason, it is recommended that resource names that do not expose anysensitive information.
Communicating to the internet
An instance hasdirect internet access only if both of the followingconditions are true:
- The instance has anexternal IPaddress.
- The instance's VPC network uses adefault route whose next hopis the default internet gateway.
Instances can also access the internet indirectly, by connecting throughCloud NAT or an instance-based proxy. For additionalconsiderations, including firewall rule configuration, seeInternet accessrequirements.
Idle connections
Google Cloud VPC networks implement 10-minute connectiontracking for IP protocols that have a concept of aconnection (TCP forexample). This means that inbound packets associated with an establishedconnection are permitted as long as at least one packet is sent or received forthe connection within the last 10 minutes. If no packets for the connectionhave been sent or received for 10 minutes or longer, the idle connection'stracking entries are removed. After the connection's tracking entries have beenremoved, Google Cloud does not permit additional inbound packets until atleast one new outbound packet has been sent. This connection tracking applies toall sources and destinations – bothinternal and external IPaddresses .
To prevent idle connections, do the following:
Set operating systemTCP keep-alive parameters to a time frame ofless than 10 minutes. This ensures that atleast one packet is sent within the time frame.
Ensure applications that open TCP connections do so with the
SO_KEEPALIVEoption enabled.
The following examples demonstrate how to set operating system TCP keep-aliveparameters with an interval value of one minute. Consult your application orsoftware library's documentation to determine how to configure it to useSO_KEEPALIVE.
ipv6 settings. Thekeepalive settings forIPv4 also apply to IPv6.Linux
Run the following command:
$sudo /sbin/sysctl -w net.ipv4.tcp_keepalive_time=60 net.ipv4.tcp_keepalive_intvl=60 net.ipv4.tcp_keepalive_probes=5/etc/sysctl.conf file.SeeLinux TCP Keepalive HOWTO for additional information.
macOS
Run the following command:
$sudo sysctl -w net.inet.tcp.always_keepalive=1 net.inet.tcp.keepidle=60000 net.inet.tcp.keepinit=60000 net.inet.tcp.keepintvl=60000Windows
Under the registry pathHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\, add the following settings, using theDWORD data type, or edit the values if the settings already exist:
KeepAliveInterval: 1000KeepAliveTime: 60000TcpMaxDataRetransmissions: 10
Accessing Compute Engine as a different SSH user
By default, thegcloud compute command-line tool uses the$USER variable toadd users to the/etc/passwd file for connecting to virtual machine instancesusing SSH. You can specify a different user using the--ssh-key-file PRIVATE_KEY_FILE flag when running thegcloud compute sshcommand. For example:
gcloud compute ssh example-instance --ssh-key-file my-private-key-fileSee thegcloud reference documentation formore information.
Interacting with the serial console
You can enable interactive access to an instance's serial console so you canconnect and troubleshoot instances through the serial console.
To learn more, readInteracting with the Serial Console.
Avoiding packet fragmentation to instances built from custom images
The VPC network has a default maximum transmission unit (MTU)of1460 bytes for Linux images and Windows Server images. However, thenetwork MTU can be changed. For details, see themaximum transmission unit overview in the VPCdocumentation.
When creating client applications that communicate with Compute Engineinstances over UDP sockets, you can avoid fragmentation if you set the maximumsize of the UDP datagram's data to 28 bytes less than the network MTU. Forexample, if the network's MTU is 1460 bytes, you can send up to 1432 bytes ofUDP data per packet without fragmentation. If the network's MTU is 1500 bytes,you can send up to 1472 bytes of UDP data without fragmentation. The 28 bytesare used for an IPv4 packet header (20 bytes) and a UDP datagram header(8 bytes). You can set the network's MTU to a maximum of 8896 bytes.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-09 UTC.