Disclaimer: this article may be contributed by the community or involve third-party product information. We recommend that you visit the community or the official website of third-party products for help and support. Third-party products will not be provided by Alibaba Cloud after-sales support. This document is for reference only. Alibaba Cloud makes no guarantee by express or any other means.
Overview
When you cannot access a service on a Linux instance, one of the possible causes is that the process of the service is not running. The following are some common services of Linux instances and their impact when they are not running.
Service | Description | Port of the default listener | Impact of not running |
SSH | Remote connection | 22 | Unable to connect remotely through SSH |
Web | Web service |
80(HTTP),443(HTTPS) |
The website is inaccessible. |
MySQL | Add a MySQL data source | 3306 | Cannot access database |
This topic describes how to start a common service on a Linux instance and check whether the ports of these services are listening.
Detail
Alibaba Cloud reminds you that:
- Before you perform operations that may cause risks, such as modifying instance configurations or data, we recommend that you check the disaster recovery and fault tolerance capabilities of the instances to ensure data security.
- You can modify the configurations and data of instances including but not limited to Elastic Compute Service (ECS) and Relational Database Service (RDS) instances. Before the modification, we recommend that you create snapshots or enable RDS log backup.
- If you have authorized or submitted sensitive information such as the logon account and password in the Alibaba Cloud Management Console, we recommend that you modify such information in a timely manner.
To clearly display the operation process, here we take the CentOS 7 system as an example. For other Linux distributions, see the corresponding official documentation. To use a redis-py client to connect to an ApsaraDB for Redis instance, perform the following steps:
- Remotely connect to the Linux instance. For more information about how to log on remotely, see ECS connection methods overview.
Note: If you cannot log on to a Linux instance by using SSH, see troubleshooting guide when you cannot remotely log on to a Linux instance by using SSH.
- Run the following command in a Linux instance to check the listening port status of the target service. Ensure that no result is returned, that is, the port of the target service is not listening.
netstat -ntlp | grep [$Port]
Note:[$Port] indicates the Port that the target service listens on. The actual Port on site shall prevail. If you have modified the default port of the target service, replace it with the modified port.
If the system returns the information about the target port and the listening status is LISTEN, the target service is running and does not need to be started. In this case, we recommend that you check the service configurations, system firewalls, and ECS security groups, or see ECS FAQs. - Run the following command to start the target service:
systemctl start [$Service]
Note:
If no result is returned, the command was executed. If an error is returned, fix the error according to the error message.
- [$Service] indicates the name of the target Service. The name on site is subject to the actual situation.
- If you are starting the SSH service, the service name is
sshd
. - To start a third-party service, such as Nginx, Tomcat, or MySQL, see the official website of the third-party service for the corresponding start command.
- Run the following command to check the status of the target service:
systemctl status [$Service]
If the system returns the following result, the target service is in running state.
Note: The SSH service is used as an example. The on-site configuration is subject to the actual conditions.
- Run the following command to check the listening port status of the target service:
netstat -ntlp | grep [$Port]
If the system returns the following result, the port of the target service is in the listening state.
Documentation
- Check whether TCP port 80 is available
- Troubleshooting guidelines if you cannot remotely log on to a Linux instance through SSH
- FAQ about ECS
Application scope
- Elastic Compute Service