查看端口占用情况

1
2
netsh interface ipv4 show excludedportrange protocol=tcp
netsh interface ipv4 show excludedportrange protocol=udp

上述两条命令可以查看端口被占用情况,输出结果形如:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
协议 tcp 端口排除范围

开始端口 结束端口
---------- --------
1536 1635
1636 1735
1736 1835
1836 1935
1936 2035
2036 2135
2136 2235
2236 2335
5357 5357
50000 50059

如果端口在开始端口和结束端口的范围内,那么可能被占用。

修改代理端口

v2Ray 在启动时疑似会自动修改 config.json 文件以及Win10中 设置→网络和Internet→代理→手动代理设置 中的端口。因此在 v2Ray 的设置中直接修改端口为一个没被占用的端口即可。

PowerShell 命令行代理

在使用 git clone 时遇到错误:

1
2
fatal: unable to access 'https://github.com/Berkeley-CS61B/library-sp24/':
Failed to connect to 127.0.0.1 port 10808 after 2024 ms: Couldn't connect to server

运行

1
git config --global -l

后得到:

1
http.https://github.com.proxy=socks5://127.0.0.1:10808

这个配置项指的是在访问 https://github.com 时,使用代理 socks5://127.0.0.1:10808,这与修改过的端口不符。因此只需要使用

1
git config --global http.https://github.com.proxy socks5://127.0.0.1:20808

将端口修正即可。