This topic describes the common errors in custom runtimes and describes how to troubleshoot the errors.
Failed to start a function instance
Error
The function cannot be started. Failed to start function instance. Error: the file /code/bootstrap is not exist
Possible causes and troubleshooting methods
If a function instance fails to be started, the possible cause is that an exception occurred for the startup command or the startup command does not exist.
By default, if the startup command is not specified, Function Compute uses
/code/bootstrap
. If the code package does not contain the /code/bootstrap file, add a/code/bootstrap
script to the code package or change the startup command.If the startup command is specified, check whether the /code/bootstrap file exists.
For information about how to configure the startup command, see Create a function.
A function instance failed to pass the health check
Error
Function instance health check failed on port 9001 in 120 seconds.\nLogs:
Possible causes and troubleshooting methods
If a function instance fails to pass the health check, the possible cause is that the IP address or port that is specified for the listener in the code is incorrect. After a function instance is started, the Function Compute platform checks the connectivity of the IP port. If no result is returned for the connectivity check during the timeout period, the Function instance health check failed
error is returned.
The IP address and port that is specified for the listener must meet the following requirements.
IP address
Specify the IP address for the listener to
0.0.0.0
or*
. We recommend that you do not set the IP address to127.0.0.0
orlocalhost
in the code.Port
Specify the port for the listener to be the same as the listener port that is configured in the Function Compute instance. The default listener port in a custom runtime is
9000
.If you use the default listener port, make sure that the port on which the HTTP server listens is
9000
in the code.If you specified a listener port in the Function Compute instance, make sure that the port on which the HTTP server listens in the code is the same as the listener port that you specified.
For information about the listener port, see Create a function.
The process of a function instance exited unexpectedly
Error
Function instance exited unexpectedly(code 2, message:no such file or directory) with start command '/code/bootstrap '.
Logs:
Function instance exited unexpectedly
indicates that the startup process of the function instance unexpectedly exited.code 2, message:no such file or directory
indicates the Linux exit code of the startup process and the meaning of the exit code.with start command '/code/bootstrap '
shows the startup command of the function instance.
The Linux exit code of a process and the meaning of the exit code are provided for reference. Identify the cause for the exited process in the error log.
Possible causes and troubleshooting methods
The startup command is not executable
The function cannot be started. Function instance exited unexpectedly(code 13, message:permission denied) with start command '/code/bootstrap '.
If the instance startup command is not executable, the exit code in the error message is
code 13, message:permission denied
. You can execute thechmod 755 bootstrap
,chmod 777 bootstrap
, orchmod +x bootstrap
command to make the startup command executable before you package the code.The specified file does not exist
Function instance exited unexpectedly(code 2, message:no such file or directory) with start command 'python3 not_exist_file.py '. Logs:xxx
If the file that you specify in the startup command does not exist, the exit code in the error message is
code 2, message:no such file or directory
. In some cases, the exit code in the error message may not becode 2, message:no such file or directory
, or an exit code may not be included in the error message. In this case, you must troubleshoot the error based on the error log.The following section describes the error messages that are returned for different programming languages when the file that you specify in the startup command does not exist.
The file is in an invalid format
Function instance exited unexpectedly(code 8, message:exec format error) with start command '/code/bootstrap '. Logs:
The custom runtime runs on a 64-bit x86 Linux system. Make sure that the startup files are supported by the system. If the startup command is a shell script, make sure that the file is in a format supported by Linux and contains the shell shebang
#!
. If the startup command is a binary executable file, make sure that the file is an executable and linkable format (ELF) file that is compatible with Linux operating systems. The following section describes the file format errors.An error occurs in the shell shebang of the startup command
If the shell script does not contain shebang, or the shebang content is incorrect, the instance exit code is
8 exec format error
. In this case, you must add the correct shebang in the first line of the shell script.If you want to run the script as a bash file, add the
#!/usr/bin/env bash
command or#!/bin/bash
command in the first line of the shell script. We recommend that you add the#!/usr/bin/env bash
command. In a custom runtime environment,/bin/sh
is equal to/bin/bash
. You can also add the#!/usr/bin/env sh
command or#!/bin/sh
command in the first line of the shell script.The shell script of the startup command is for Windows OSs
Run the following test script.
#!/usr/bin/env bash node /code/index.js
The following error message is returned.
Function instance exited unexpectedly(code 127, message:key has expired) with start command '/code/bootstrap '. Logs:/usr/bin/env: 'bash\r': No such file or directory
In the error log,
bash\r
indicates thatbash
is followed by an additional\r
. In the UNIX OS, you can end a line with\n
. In the Windows OS, you can end a line with\r\n
. The provided script is in a format that is designed for Windows OSs.If you create your script on a Windows OS, you must convert the script to a format that is compatible with UNIX OSs. You can run the
dos2unix
command on a Linux OS or use the WebIDE feature of Function Compute to convert your script. For more information, see How do I use the Web IDE feature of Function Compute to convert file formats?.The startup command is a binary executable file that is not compatible with Linux OSs
If the startup command is an executable file, make sure that the file is in an ELF file that is compatible with Linux OSs. For example, the following error message is returned if you use the default configuration
GOOS=darwin GOARCH=arm64
to compile the Golang code and test the packaged code on a Mac computer that runs on the M1 chip.Function instance exited unexpectedly(code 8, message:exec format error) with start command './main '. Logs:
The instance exit code is
8 exec format error
, which indicates that the file is in an invalid format. You must add theGOOS=linux GOARCH=amd64
configuration when you compile the code. For more information, see Compilation and deployment of code packages.
Common exit codes
The following section describes other common exit codes.
Exit Code 137
In most cases, this exit code is returned due to the
OOMKilled(Out of Memory)
error that indicates that the memory is insufficient. In this case, you can upgrade the memory configuration for the function.
Additional information
If any error that is not listed in this topic occurs, see the Custom Runtime FAQ.