Updated on 2026-08-27 GMT+08:00

Using Node.js to Run Node.js Programs

Scenarios

Node.js is an open-source project management software. It provides functions such as project management, Wiki, and news, and integrates tools such as GIT, SVN, and CVS. The Node.js application image is running Ubuntu 24.04 and deployed with Docker. It comes pre-installed with Node.js and all required runtime environments. This section describes how to use a Node.js application image to run a Node.js application.

If your Node.js application image was purchased before August 28, 2026, see Using Node.js to Run Node.js Programs (Historical Version) for instructions.

Resource Planning and Costs

Resource

Configuration

Description

Cloud server

  • vCPUs: 2
  • Memory: 2 GiB

Select appropriate instance specifications based on your service requirements.

Image

Node.js

Select the Node.js application image.

Network

EIP

By default, a fixed EIP and a fixed private IP address are assigned to a FlexusL instance.

Security group

Inbound rule:

  • Protocol/Application: TCP
  • Port: 3000
  • Source: 0.0.0.0/0

3000: Tests the Node.js script execution.

Procedure

Step

Description

Step 1: Purchase FlexusL Instances

Purchase a FlexusL instance and select the Node.js application image.

Step 2: Configure Security Groups

Add inbound security group rules to ensure that the application pre-installed in the image can be accessed.

Step 3: Run the Node.js Program

Use the Node.js application image to run a Node.js application.

Step 1: Purchase FlexusL Instances

  1. Log in to the FlexusL console and click Buy FlexusL.
  2. Specify required parameters for the FlexusL instance.

    Parameter

    Example Value

    Description

    Region

    CN-Hong Kong

    For low network latency and quick resource access, select the region nearest to your target users. After a FlexusL instance is created, the region cannot be changed. Exercise caution when selecting a region.

    Application Images

    Node.js

    Select the Node.js application image.

    Instance Specifications

    2 vCPUs | 2 GiB of memory and 60 GiB of the system disk

    Select instance specifications as needed.

    Instance Name

    Node-Example

    Customize an instance name that is easy to identify, for example, Node-Example.

    (Optional) Associated Services

    • Data Disk: 10 GiB
    • Host Security
    • Cloud Backup Vault: 70 GB

    You can bundle any of EVS, HSS (basic edition), and CBR to your FlexusL instances as needed and set specifications as needed.

    Required Duration

    1 month

    Set the required duration.

    FlexusL supports auto-renewal. Once enabled, FlexusL instances automatically renew before they expire. If you do not enable auto-renewal during purchase, you can still enable it after your FlexusL instances are created. For more information about auto-renewal rules, see Auto-Renewal Rules.

    Quantity

    1

    Set the number of FlexusL instances to be purchased.

  3. Click Next: Confirm.

    On the displayed page, confirm the order details, read and select the agreement, and click Submit.

  4. Select a payment method and complete the payment.
  5. Go back to the FlexusL console and view the purchased FlexusL instance.

Step 2: Configure Security Groups

Add inbound security group rules to ensure that the application pre-installed in the image can be accessed.

  1. Log in to the FlexusL console and click the target resource card or instance name to go to the instance details page.
  2. In the navigation pane on the left, choose Cloud Servers and click the target server name to view its details.
  3. On the Security Groups tab, click Add Rule to add the rules listed in the following table.

    The following only lists common rules. You can add more rules as needed.

    Table 1 Security group rules

    Priority

    Action

    Type

    Protocol & Port

    Source

    Description

    1

    Allow

    IPv4

    TCP: 3000

    0.0.0.0/0

    Tests the Node.js script execution.

Step 3: Run the Node.js Program

  1. Log in to the FlexusL console.
  2. On the target resource card, choose > Reset Password to reset the password as instructed.

    A FlexusL instance does not have an initial password. If you want to log in to a FlexusL instance, set a password for it first. If you have already set a password, skip this step.

    For details, see Resetting the Password for a FlexusL Instance.

  3. Locate the target resource card and click Remote Login. In the displayed dialog box, click VNC Login and enter the username and password to log in to the FlexusL instance. The username is root, and the password is the one you set in the previous step.

    For more login methods, see Login Modes.

  4. After logging in to the cloud server, run the following command to check the Node.js version:
    node -v
    # Or
    node --version
  5. Run the following command to check the version of npm (the package manager that comes with Node.js):
    npm-v
    # Or
    npm--version
  6. Run the node command to enter the runtime environment. Paste the following example script after the ">" symbol and press Enter to run the script and start the service.
    const http = require('http');
    const server = http.createServer((req, res) => {
    res.setHeader('Content-Type', 'text/plain;charset=utf-8');
    res.end('Hello World\n');
    // After the request is processed, stop the service and exit the process.
    server.close(() => process.exit(0));
    });
    server.listen(3000, '0.0.0.0', () => {
    console.log('hello world');
    console.log('Service started. It will automatically stop after handling one request to prevent resource consumption.');
    });

  7. Access the following address in your local browser to view the execution result:

    http://<FlexusL-instance-EIP>:3000