All Products
Search
Document Center

Function Compute:Error handling

Last Updated:Jan 08, 2026

This topic describes common error types in the Custom Runtime environment and how to troubleshoot them.

Instance failed to start (Failed to start function instance)

Error example

The function cannot be started. Failed to start function instance. Error: the file /code/bootstrap is not exist

Troubleshooting

An instance fails to start if the start command is invalid or does not exist.

  • If you do not set the Start Command, Function Compute uses /code/bootstrap as the default. If this file is not in your code package, add a /code/bootstrap script or set the Start Command.

  • If you set the Start Command, check for an error message such as Error: The file xxx does not exist and confirm that the specified file exists.

For more information about setting the Start Command, see Create a function.

Instance failed health check (Function instance health check failed)

Error example

Function instance health check failed on port 9001 in 120 seconds.\nLogs:

Troubleshooting

An instance fails the health check, usually because the listening IP address or port is set incorrectly in the code. After the instance starts, the platform performs a Layer 4 connectivity check on the port configured for the function. If the check does not pass within the timeout period, a Function instance health check failed error is returned.

The listening address and port must meet the following conditions.

  • Listening address

    The listening IP address in the code must be set to 0.0.0.0 or *. Do not set it to 127.0.0.0 or localhost.

  • Listening port

    The listening port, which defaults to 9000 for a custom runtime, must match the port set in the function configuration.

    • If you use the default port, make sure the HTTP server in your code also listens on port 9000.

    • If you set the Listening Port, make sure the HTTP server in your code listens on the same port.

For more information about setting the Listening Port, see Create a function.

Instance process exited unexpectedly

Error example

Function instance exited unexpectedly(code 2, message:no such file or directory) with start command '/code/bootstrap '.
Logs:
  • Function instance exited unexpectedly: The instance startup process exited unexpectedly.

  • code 2, message:no such file or directory: The Linux exit code of the instance startup process and its description.

  • with start command '/code/bootstrap ': The start command for the instance.

Note

The process exit code and its description are for reference only. They do not definitively indicate the reason for the instance exit. The exit code may be custom-defined in your code and may not correspond to the meaning of a standard Linux exit code.

Troubleshooting

  • The start command does not have execute permissions

    The function cannot be started. Function instance exited unexpectedly(code 13, message:permission denied) with start command '/code/bootstrap '.

    If the instance start command does not have execute permissions, the exit code in the error message is usually code 13, message:permission denied. Before you package the code, grant execute permissions to the file by running chmod 755 bootstrap, chmod 777 bootstrap, or chmod +x bootstrap.

  • File not found

    Function instance exited unexpectedly(code 2, message:no such file or directory) with start command 'python3 not_exist_file.py '.
    Logs:xxx

    If a file specified in the start command does not exist, the error message usually includes the exit code code 2, message:no such file or directory. In some cases, the exit code may not be code 2, message:no such file or directory, or no exit code is provided. In this situation, you must use the error log to troubleshoot the issue.

    The following sections describe the errors that different start commands return for non-existent files.

    • Python

      When the instance start command is python3 not_exist_file.py, the exit code is code 2, message:no such file or directory.

      If you add this start command to a shell script, as shown in the following example, and then change the start command to /code/bootstrap, an error occurs when you run the function, indicating that /code/not_exist_file.py does not exist.

      Example shell script

      #!/bin/bash
      python3 not_exist_file.py

      Error message

      Function instance exited unexpectedly(code 2, message:no such file or directory) with start command '/code/bootstrap '.
      Logs:python3: can't open file '/code/not_exist_file.py': [Errno 2] No such file or directory
    • Node.js

      When the instance start command is npm run start and the start script in the package.json file is node ./not_exist_file.js, the following error is reported.

      Function instance exited unexpectedly(code 1, message:operation not permitted) with start command 'npm run start '.
      Logs:> nodejs-express@0.0.0 start /code
      > node ./not_exist_file.js
      
      internal/modules/cjs/loader.js:905
        throw err;
        ^
      
      Error: Cannot find module '/code/not_exist_file.js'
          at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
          at Function.Module._load (internal/modules/cjs/loader.js:746:27)
          at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
          at internal/main/run_main_module.js:17:47 {
        code: 'MODULE_NOT_FOUND',
        requireStack: []
      }
      npm ERR! code ELIFECYCLE
      npm ERR! errno 1
       ERR! nodejs-express@0.0.0 start: `node ./not_exist_file.js`
       npm ERR!
       ERR! Failed at the nodejs-express@0.0.0 start script.
      npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
      
      npm ERR! A complete log of this run can be found in:
      npm ERR!     /root/.npm/_logs/2022-10-31T08_02_29_434Z-debug.log

      The error log shows Error: Cannot find module '/code/not_exist_file.js', which means the /code/not_exist_file.js file does not exist. The exit code is code 1, message:operation not permitted.

      A similar error occurs if the instance start command is node ./not_exist_file.js.

    • Java

      When the instance start command is java -Dserver.port=9000 -jar target/not_exist_file.jar, the following error is reported.

      Function instance exited unexpectedly(code 1, message:operation not permitted) with start command 'java -Dserver.port=9000 -jar target/not_exist_file.jar '.
      Logs:Error: Unable to access jarfile target/not_exist_file.jar

      The error log shows Unable to access jarfile target/not_exist_file.jar, which means the target/not_exist_file.jar file does not exist. The exit code is code 1, message:operation not permitted.

    • PHP

      When the instance start command is php not_exist_file.php, the following error is reported.

      Function instance exited unexpectedly(code 1, message:operation not permitted) with start command 'php not_exist_file.php '.
      Logs:Could not open input file: not_exist_file.php

      The error log shows Could not open input file: not_exist_file.php, which means the not_exist_file.php file does not exist. The exit code is code 1, message:operation not permitted.

    • .NET Core

      When the instance start command is dotnet ./target/NotExistFile.dll, the following error is reported.

      Function instance exited unexpectedly(code 145) with start command 'dotnet ./target/NotExistFile.dll '.
      Logs:Could not execute because the application was not found or a compatible .NET SDK is not installed.
      Possible reasons for this include the following:
        * You intended to execute a .NET program:
            The application './target/NotExistFile.dll' does not exist.
        * You intended to execute a .NET SDK command:
            It was not possible to find any installed .NET SDKs.
            Install a .NET SDK from:
              https://aka.ms/dotnet-download

      The error log provides detailed troubleshooting methods. The error occurs because the ./target/NotExistFile.dll file does not exist or a compatible .NET SDK is not installed. The exit code is code 145.

    • Ruby

      When the instance start command is ruby not_exist_file.rb, the following error is reported.

      Function instance exited unexpectedly(code 1, message:operation not permitted) with start command 'ruby not_exist_file.rb '.
      Logs:Traceback (most recent call last):
      ruby: No such file or directory -- not_exist_file.rb (LoadError)

      The error log shows No such file or directory -- not_exist_file.rb, which means the not_exist_file.rb file does not exist. The exit code is code 1, message:operation not permitted.

  • Incorrect file format

    Function instance exited unexpectedly(code 8, message:exec format error) with start command '/code/bootstrap '.
    Logs:

    The Custom Runtime environment is an x86-64 Linux system. Ensure that the start command file is compatible with this environment. If the start command is a shell script, ensure that the file is in the Linux format and includes a shebang line (#!). If the start command is a binary executable file, ensure that it is an Executable and Linkable Format (ELF) file that is compatible with Linux.

    • Incorrect shebang line in the start command shell script

      If a shell script is missing the shebang line or the line is incorrect, the instance exit code is usually 8 exec format error. To resolve this issue, you must add the correct shebang line at the beginning of the file.

      To run the script using Bash, add #!/usr/bin/env bash or #!/bin/bash to the first line of the file. We recommend that you use #!/usr/bin/env bash. In the Custom Runtime environment, /bin/sh is an alias for /bin/bash. Therefore, you can also use #!/usr/bin/env sh or #!/bin/sh.

    • The start command shell script is in Windows format

      Run the following test script.

      #!/usr/bin/env bash
      node /code/index.js

      The following error is reported.

      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 an extra \r character after bash. The line feed character for Unix files is \n, while the line feed character for Windows files is \r\n. This indicates that the file is in the Windows format.

      If you create the script on a Windows system, you must convert the file format to the Unix format. You can convert the file by running the dos2unix command in a Linux system or using the Web IDE in Function Compute. For more information, see How do I use the Web IDE of Function Compute to convert file formats?.

    • The start command is a binary executable file

      If the start command is an executable file, ensure that the file is a Linux-compatible ELF file. For example, on a Mac computer with an M1 chip, if you compile Go code using the default GOOS=darwin GOARCH=arm64 configuration, and then package, upload, and test the executable, the following error message is returned.

      Function instance exited unexpectedly(code 8, message:exec format error) with start command './main '.
      Logs:

      The instance exit code 8 exec format error indicates an incorrect file format. You must add the configuration GOOS=linux GOARCH=amd64 at compile-time. For more information, see Compile and deploy a code package.

      How to determine the format of an executable file

      • The following output shows the format of an executable file compiled with GOOS=darwin GOARCH=arm64.

        $ file main
        main: Mach-O 64-bit arm64 executable, flags:<|DYLDLINK|PIE>

        The file format is Mach-O and the CPU architecture is arm64, which is incompatible with the Custom Runtime environment.

      • The following output shows the format of an executable file compiled with GOOS=linux GOARCH=amd64.

        $ file main
        main: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=xxx, not stripped

        The file format is ELF and the CPU architecture is x86-64, which is compatible with the Custom Runtime environment.

      Note
      • Executable files on Linux systems are typically in ELF format.

      • Executable files on macOS systems are in Mach-O format.

      • Executable files on Windows systems are in PE format.

  • Common exit codes

    In addition to the exit codes listed above, other common errors can occur.

    • Exit Code 137

      The program received a SIGKILL signal and exited unexpectedly. This is typically an OOMKilled (Out of Memory) error, which occurs when a program is terminated because of insufficient memory. In this case, you can increase the memory allocated to the function.

More information

For errors not listed in this topic, see Custom Runtime FAQ.