網路服務連線測試: Difference between revisions

Jump to navigation Jump to search
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
如何測試與排除網路服務連線問題。找出問題發生的地方:(1) 伺服器上的本地服務 (localhost) (2) 從區域網路到伺服器 (3) 從廣域網路到伺服器
如何測試與排除網路服務連線問題。找出問題發生的地方:(1) 伺服器上的本地服務 (localhost) (2) 從區域網路到伺服器 (3) 從廣域網路到伺服器


: [[Test connectivity for the web service]] in English
{{LanguageSwitcher | content = [[Test connectivity for the web service | EN]], [[網路服務連線測試 | 漢字]] }}


=== 如何連線到網路服務 (Web 服務) ===
=== 如何連線到網路服務 (Web 服務) ===
Line 32: Line 32:
# {{kbd | key = telnet 127.0.0.1 <PORT>}} 如果連接網頁服務失敗。它將顯示消息:"telnet: 無法連接到遠程主機:連接被拒絕"
# {{kbd | key = telnet 127.0.0.1 <PORT>}} 如果連接網頁服務失敗。它將顯示消息:"telnet: 無法連接到遠程主機:連接被拒絕"


如果安裝了Python,則使用替代網站服務
如果安裝了 Python 或 Node.js,則可使用替代網站服務


* (對於python 2.x) {{kbd | key=<nowiki>python -m SimpleHTTPServer <port></nowiki>}}<ref>[https://docs.python.org/2/library/simplehttpserver.html 20.19. SimpleHTTPServer 簡單HTTP請求處理器 — Python 2.7.17 文件]</ref>
* (適用 python 3.x) {{kbd | key=<nowiki>python -m http.server <port></nowiki>}} (預設 port: 8000)<ref>[https://docs.python.org/3/library/http.server.html http.server HTTP servers — Python 3.13.2 documentation]</ref>
* (對於python 3.x) {{kbd | key=<nowiki>python -m http.server <port></nowiki>}}<ref>[https://docs.python.org/3.8/library/http.server.html?highlight=http%20server#module-http.server http.server — HTTP伺服器 — Python 3.8.1 文件]</ref>
* (適用 Node.js) {{kbd | key=<nowiki>npx http-server -p <port></nowiki>}} (預設 port: 8080)<ref>[https://github.com/http-party/http-server http-server: a simple static HTTP server]</ref>


== 測試本地網路服務的連接性 ==
== 測試本地網路服務的連接性 ==
WAN &#9675; -------&gt; &#9675; LAN -------&gt; <span style="color:red">&#9679; 伺服器</span>
WAN &#9675; -------&gt; &#9675; LAN -------&gt; <span style="color:red">&#9679; 伺服器</span>


: [[Image:Owl icon.jpg]] 如果您有管理權限通過SSH或遠程桌面服務登錄伺服器。
{{Tips}} 如果您有管理權限通過SSH或遠程桌面服務登錄伺服器。


=== 檢查您的電腦/伺服器是否被指派了IP位址 ===
=== 檢查您的電腦/伺服器是否被指派了IP位址 ===
Line 92: Line 92:
[https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers 維基百科 - TCP和UDP埠號列表]
[https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers 維基百科 - TCP和UDP埠號列表]


 
Example output of netstat command, more on [[Find process running on port]]
[[Find process running on port]]
 
* {{Linux}}
** [http://linux.die.net/man/1/nmap nmap] "Network exploration tool and security / port scanner." e.g. {{kbd | key = <nowiki>nmap -p 80,443 ip</nowiki>}}
** [http://linux.die.net/man/8/ss ss] "utility to investigate sockets" e.g. {{kbd | key = <nowiki>ss -tnlp | grep 80</nowiki>}} or using OR operator<ref>[http://www.thegeekstuff.com/2011/10/grep-or-and-not-operators/ 7 Linux Grep OR, Grep AND, Grep NOT Operator Examples]</ref> {{kbd | key = <nowiki>ss -tnlp | grep '80\|443'</nowiki>}}
** [http://linuxcommand.org/man_pages/ps1.html ps] List the current processes. Input {{kbd | key = <nowiki>ps -aux | grep "PORT_NUMBER"</nowiki>}} e.g. {{kbd | key = <nowiki>ps -aux | grep 443</nowiki>}}
** [https://docs.oracle.com/cd/E19504-01/802-5753/6i9g71m3i/index.html netstat Command] {{kbd | key=<nowiki>netstat -tulpn | grep LISTEN</nowiki>}} e.g.
** [https://docs.docker.com/engine/reference/commandline/port/ docker port | Docker Documentation]
 
Example output of netstat command
<pre>
<pre>
$ netstat -tulpn | grep LISTEN
$ netstat -tulpn | grep LISTEN
Line 110: Line 100:
// means the 80 port service is running
// means the 80 port service is running
</pre>
</pre>
* {{Win}}
** Using the software [http://www.nirsoft.net/utils/cports.html CurrPorts] to check the process and port. e.g. Apache will not running if the 80 port was occupied by skype<ref>[http://stackoverflow.com/questions/4705005/how-to-solve-wamp-and-skype-conflict-on-windows-7 How to solve WAMP and Skype conflict on Windows 7? - Stack Overflow]</ref>.


=== Check if a port is blocked by browser ===
=== Check if a port is blocked by browser ===
Line 173: Line 160:
# [http://check-host.net/ 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. {{access | date=2015-08-02}}
# [http://check-host.net/ 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. {{access | date=2015-08-02}}


== Related articles ==
 
== 相關文章 ==
* [https://errerrors.blogspot.com/2022/07/blog-post.html 怎樣排除網路連線逾時 (network connection timed out) 問題]
* [https://errerrors.blogspot.com/2022/07/blog-post.html 怎樣排除網路連線逾時 (network connection timed out) 問題]


Navigation menu