Test connectivity for the web service
find the problem occurred: (1) local service at the server (localhost) (2) from LAN to server (3) from WAN to server
- 網路服務連線測試 in Mandarin
How to connect to the web service[edit]
If the service is the web server:
- (1) Open the browser, (2) Type the address: http://127.0.0.1 or http://the.domain
- Linux lynx command:
- telnet command
- telnet 127.0.0.1 <PORT> e.g. telnet 127.0.0.1 80 or telnet the.domain 80
- (after telnet-ed the web 80 port, key in) get + SPACE[3]
- curl[4]: curl -vL http://IP:Port
- (optional if curl command was not installed) Learn how to install & run cURL on Windows/MacOSX/Linux | Ubidots Help Center
- commands e.g.
- (1) Write output to <file> instead of stdout using curl -voL https://www.google.com
- (2) Write output to stdout using curl -vL https://www.google.com or curl -voL /dev/null https://www.google.com
- (3) Write output to <file> with the remote file name using curl -vOL https://www.google.com/index.html
- If failed. It will show the message: "failed: Connection refused"
- Linux wget software e.g. wget https://www.google.com
- use the third-party website monitoring the services: Web Ping
If the service is not the web server, use telnet instead
- (optional) Install Telnet Client | Microsoft Docs on Win . Bring telnet back on macOS high Sierra – Ayuth Mangmesap (blackSource) – Medium on Mac
- telnet 127.0.0.1 <PORT> If failed to connect the web service. It will show the message: "telnet: Unable to connect to remote host: Connection refused"
Using alternative web services if the Python was installed
- (for python 2.x) python -m SimpleHTTPServer <port>[5]
- (for python 3.x) python -m http.server <port>[6]
Test connectivity for the local web service[edit]
WAN ○ -------> ○ LAN -------> ● server
Check if your computer/server Is being assigned the IP Address[edit]
- Linux : (1) Check the IP Address. ifconfig. (2) Re-assign the IP Address and restart the networking service. service network restart for CentOS[7]
- Win : Check the IP Address. ifconfig/all
- More on Network problem
Check if web service has started successfully?[edit]
- Apache /etc/init.d/httpd status on CentOS7 [8]
- nginx sudo service nginx status on CentOS7
- Docker container docker ps to check if the container is running & expose the port[9]
Check if MySQL has started successfully?[edit]
Using lsof command[edit]
The command lsof -i:3306 is used in Unix-like operating systems to list open files and the processes that opened them. Let's break down the command:
lsof: This stands for "List Open Files". It's a command-line utility that displays information about files opened by processes. In Unix and Linux, everything is treated as a file (including hardware devices, sockets, and directories), so lsof is a powerful tool for system administrators to monitor and troubleshoot system behavior.
-i: This option tells lsof to show only network files. In Unix and Linux, network connections are treated as files. The -i option can be used to filter connections based on the Internet address or network protocol.
- 3306: This specifies the port number. Port 3306 is commonly used by MySQL, a popular database management system. By including :3306, you are asking lsof to list all network files (which includes socket connections) that are associated with port 3306.
Example output: localhost:mysql (LISTEN) means the MySQL has started successfully
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME mysqld 93034 account 29u IPv4 0xxxx 0t0 TCP localhost:mysql (LISTEN)
Using ps command[edit]
- ps aux | grep mysql on Mac
Example output if MySQL has started successfully:
_mysql 11083 0.3 0.2 409657280 31424 ?? Ss 2:12下午 0:01.07 /usr/local/mysql/bin/mysqld --user=_mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/usr/local/mysql/data/mysqld.local.err --pid-file=/usr/local/mysql/data/mysqld.local.pid --keyring-file-data=/usr/local/mysql/keyring/keyring --early-plugin-load=keyring_file=keyring_file.so ACCOUNT 12349 0.0 0.0 408645328 1648 s011 S+ 2:14下午 0:00.00 grep mysql
Example output if MySQL has NOT started successfully:
ACCOUNT 12349 0.0 0.0 408645328 1648 s011 S+ 2:14下午 0:00.00 grep mysql
Check if a port was occupied by other process?[edit]
Check the port if used by other protocol
- Linux
- nmap "Network exploration tool and security / port scanner." e.g. nmap -p 80,443 ip
- ss "utility to investigate sockets" e.g. ss -tnlp | grep 80 or using OR operator[10] ss -tnlp | grep '80\|443'
- ps List the current processes. Input ps -aux | grep "PORT_NUMBER" e.g. ps -aux | grep 443
- netstat Command netstat -tulpn | grep LISTEN e.g.
- docker port | Docker Documentation
Example output of netstat command
$ netstat -tulpn | grep LISTEN tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN - // means the 80 port service is running
Check if a port is blocked by browser[edit]
Check if a port is blocked by browser[12]
- Chrome net/base/port_util.cc - chromium/src.git - Git at Google
- Fetch Standard 2.9. Port blocking
Is the port opened for external users?[edit]
Check the OS firewall or protected by antivirus software
- Linux
- iptables: (1) iptables -L to list all rules[13] (2) rule with smaller line-number will override the rule with larger line-number[14]
- FirewallD rules: (1) sudo firewall-cmd --get-default-zone return 'public' (2) sudo firewall-cmd --list-all --zone=public[15] (3) Allow port with FirewallD
- SELinux Policy Management: (1) After installed policycoreutils-python[16], input semanage port -l to list open ports. (2) Allow port with semanage.
- Win Windows Firewall with Advanced Security -> configure firewall rules
- protected by antivirus software?
- Linux
- connect to localhost ex: telnet 127.0.0.1 23 where 23 is the port number where the service running
- Install Telnet Client on Win
- if the local service is web server, you can also try lynx http://127.0.0.1 for Linux
- double check the server/service logs
Test connectivity from LAN to the server[edit]
WAN ○ -------> ● LAN -------> ● server
Testing on LAN (local network, subnet scope): The different servers between LAN or with the same ip class (ex: 1.2.3.*) and may not have the firewall limit. Private network / Private IP address
- Is the service alive?
- Connect to the internal IP eg: telnet 172.18.0.1 23 (1) IP start with 172.18... is Private IP Network Numbers (2) where 23 is the port number where the service running
- If the local service is web server, you can also try to connect the internal IP e.g. lynx http://172.18.0.1 for Linux
- Double check the server/service logs
- Is the internal IP correct?
Test connectivity from WAN to the remote server[edit]
WAN ● -------> ● LAN -------> ● server
We met the trouble on WAN (wide area network). If we do no have the administrative permission, the tests we can do as follows:
- Down for everyone or just me? more on Web Ping
- Switch to different ISP? Is hardware firewall enabled?
- Is gateway alive?
- Is DNS alive?
- Is the external IP correct?
- If the firewall rule is IP specified, verify the IP if correct from What Is My IP Address? or web access log.
- Query the IP Address Details - ipinfo.io. e.g. Input the command curl ipinfo.io/ip[17] for Mac & Linux
- Is the port was opened for external users? Open Port Check Tool - Port Forwarding Port Check Tool
- Is institutional/ISP firewall enabled? Contact your MIS. (Management information system) of your company or ISP?
other issue:
- bandwidth cost too much by certain users
- exceed the request limit of (hardware) firewall
- the external connection of updated Windows was down until reboot Win
- Amazon EC2 security group
- refresh browser cache: Refresh your cache - When hitting F5 just isn't enough!
Tools[edit]
- CurrPorts: Monitoring TCP/IP network connections on Windows
- PFPortCheck Program: check TCP/UDP port from localhost(where you installed the program) to portforward.com
- TCPView for Windows
- Check server: Check host - online website monitoring, Check IP "checks the possibility of a TCP connection to host's specified port from different locations around the world." quoted from website. [Last visited: 2015-08-02]
Related articles[edit]
References[edit]
- ↑ Install and Use Lynx Browser on Ubuntu
- ↑ Lynx Users Guide v2.8.7
- ↑ HTTP Check Port 80 with the Telnet Command
- ↑ curl - How To Use
- ↑ 20.19. SimpleHTTPServer — Simple HTTP request handler — Python 2.7.17 documentation
- ↑ http.server — HTTP servers — Python 3.8.1 documentation
- ↑ How to restart the networking service? - Ask Ubuntu
- ↑ How to check running status of LAMP stack | E2E Networks Knowledgebase
- ↑ docker ps | Docker Documentation
- ↑ 7 Linux Grep OR, Grep AND, Grep NOT Operator Examples
- ↑ How to solve WAMP and Skype conflict on Windows 7? - Stack Overflow
- ↑ 開發與部署網站時需注意不要使用到 ERR_UNSAFE_PORT 不安全的埠號 | The Will Will Web
- ↑ HowTos/Network/IPTables - CentOS Wiki
- ↑ How to edit iptables rules - FedoraProject
- ↑ How To Set Up a Firewall Using FirewallD on CentOS 7 | DigitalOcean
- ↑ semanage command not found on CentOS 7 and RHEL 7
- ↑ networking - Command for determining my public IP? - Ask Ubuntu
Troubleshooting of ...
- PHP, cUrl, Python, selenium, HTTP status code errors
- Database: SQL syntax debug, MySQL errors, MySQLTuner errors or PostgreSQL errors
- HTML/Javascript: Troubleshooting of javascript, XPath
- Software: Mediawiki, Docker, FTP problems, online conference software
- Test connectivity for the web service, Web Ping, Network problem, Web user behavior, Web scrape troubleshooting
Template