[GH-ISSUE #3526] systemctl start可以启动frpc,但是reboot后,服务stopped #2816

Closed
opened 2026-05-05 13:49:15 -06:00 by gitea-mirror · 11 comments
Owner

Originally created by @yang369875 on GitHub (Jul 12, 2023).
Original GitHub issue: https://github.com/fatedier/frp/issues/3526

Bug Description

设置了systemctl enable,直接systemctl start是可以正常ssh,但是重启客户端后无法连接,查看status显示connect: network is unreachable
frpc service for config file [/home/pi/frp/frpc.ini] stopped
应该是说网络问题

frpc Version

0.51.0

frps Version

0.51.0

System Architecture

linux/arm

Configurations

#/usr/lib/systemd/system/frpc.service
[Unit]
Description=frps service
After=network.target syslog.target
Wants=network.target

[Service]
Type=simple
User=nobody
Restart=on-failure
RestartSec=5s

TimeoutStartSec=60

ExecStartPre=/bin/sleep 10
ExecStart=/home/pi/frp/frpc -c /home/pi/frp/frpc.ini

ExecStop=/bin/kill $MAINPID

ExecReload=/home/pi/frp/frpc reload -c /home/pi/frp/frpc.ini

[Install]
WantedBy=multi-user.target

Logs

pi@raspberrypi:~ $ sudo systemctl status frpc
● frpc.service - frp server
Loaded: loaded (/etc/systemd/system/frpc.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Wed 2023-07-12 09:54:16 CST; 18min ago
Process: 589 ExecStart=/home/pi/frp/frpc -c /home/pi/frp/frpc.ini (code=exited, status=0/SUCCESS)
Main PID: 589 (code=exited, status=0/SUCCESS)

7月 12 09:54:15 raspberrypi systemd[1]: Started frp server.
7月 12 09:54:16 raspberrypi frpc[589]: 2023/07/12 09:54:16 [I] [root.go:220] start frpc service for config file [/home/pi/frp/frpc.ini]
7月 12 09:54:16 raspberrypi frpc[589]: 2023/07/12 09:54:16 [W] [service.go:133] login to server failed: dial tcp xx.xx.xx.xx:7000: connect: network is unreachable
7月 12 09:54:16 raspberrypi frpc[589]: 2023/07/12 09:54:16 [I] [root.go:236] frpc service for config file [/home/pi/frp/frpc.ini] stopped
7月 12 09:54:16 raspberrypi systemd[1]: frpc.service: Succeeded.

ssh:
~ % ssh -oPort=6000 pi@xx.xx.xx.xx -v
OpenSSH_8.1p1, LibreSSL 2.7.3
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug1: Connecting to xx.xx.xx.xx [xx.xx.xx.xx] port 6000.
debug1: connect to address xx.xx.xx.xx port 6000: Connection refused
ssh: connect to host xx.xx.xx.xx port 6000: Connection refused

Steps to reproduce

...

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
Originally created by @yang369875 on GitHub (Jul 12, 2023). Original GitHub issue: https://github.com/fatedier/frp/issues/3526 ### Bug Description 设置了systemctl enable,直接systemctl start是可以正常ssh,但是重启客户端后无法连接,查看status显示connect: network is unreachable frpc service for config file [/home/pi/frp/frpc.ini] stopped 应该是说网络问题 ### frpc Version 0.51.0 ### frps Version 0.51.0 ### System Architecture linux/arm ### Configurations #/usr/lib/systemd/system/frpc.service [Unit] Description=frps service After=network.target syslog.target Wants=network.target [Service] Type=simple User=nobody Restart=on-failure RestartSec=5s # TimeoutStartSec=60 ExecStartPre=/bin/sleep 10 ExecStart=/home/pi/frp/frpc -c /home/pi/frp/frpc.ini # ExecStop=/bin/kill $MAINPID ExecReload=/home/pi/frp/frpc reload -c /home/pi/frp/frpc.ini [Install] WantedBy=multi-user.target ### Logs pi@raspberrypi:~ $ sudo systemctl status frpc ● frpc.service - frp server Loaded: loaded (/etc/systemd/system/frpc.service; enabled; vendor preset: enabled) Active: inactive (dead) since Wed 2023-07-12 09:54:16 CST; 18min ago Process: 589 ExecStart=/home/pi/frp/frpc -c /home/pi/frp/frpc.ini (code=exited, status=0/SUCCESS) Main PID: 589 (code=exited, status=0/SUCCESS) 7月 12 09:54:15 raspberrypi systemd[1]: Started frp server. 7月 12 09:54:16 raspberrypi frpc[589]: 2023/07/12 09:54:16 [I] [root.go:220] start frpc service for config file [/home/pi/frp/frpc.ini] 7月 12 09:54:16 raspberrypi frpc[589]: 2023/07/12 09:54:16 [W] [service.go:133] login to server failed: dial tcp xx.xx.xx.xx:7000: connect: network is unreachable 7月 12 09:54:16 raspberrypi frpc[589]: 2023/07/12 09:54:16 [I] [root.go:236] frpc service for config file [/home/pi/frp/frpc.ini] stopped 7月 12 09:54:16 raspberrypi systemd[1]: frpc.service: Succeeded. ssh: ~ % ssh -oPort=6000 pi@xx.xx.xx.xx -v OpenSSH_8.1p1, LibreSSL 2.7.3 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 47: Applying options for * debug1: Connecting to xx.xx.xx.xx [xx.xx.xx.xx] port 6000. debug1: connect to address xx.xx.xx.xx port 6000: Connection refused ssh: connect to host xx.xx.xx.xx port 6000: Connection refused ### Steps to reproduce 1. 2. 3. ... ### Affected area - [ ] Docs - [X] Installation - [ ] Performance and Scalability - [ ] Security - [ ] User Experience - [ ] Test and Release - [ ] Developer Infrastructure - [ ] Client Plugin - [ ] Server Plugin - [ ] Extensions - [ ] Others
gitea-mirror 2026-05-05 13:49:15 -06:00
Author
Owner

@ddddavid-he commented on GitHub (Jul 12, 2023):

遇到相同问题,退回之前版本就正常,看起来是frpc在启动时联网得问题

<!-- gh-comment-id:1632252705 --> @ddddavid-he commented on GitHub (Jul 12, 2023): 遇到相同问题,退回之前版本就正常,看起来是frpc在启动时联网得问题
Author
Owner

@gexiaopeng commented on GitHub (Jul 28, 2023):

这个情况我也有时遇到,应该是frpc启动的时候,服务器网络还没有完全设置好,解决办法可以把ExecStartPre=/bin/sleep 设置的长一点 。 其实这个也是frpc的一个bug,如果能一直间隔几秒重新连接,就没有问题了。(重连的机制可以与正常连接以后的断开机制一样,间隔1秒,2秒,4秒,8秒,16秒,后面一直20秒)

<!-- gh-comment-id:1655069562 --> @gexiaopeng commented on GitHub (Jul 28, 2023): 这个情况我也有时遇到,应该是frpc启动的时候,服务器网络还没有完全设置好,解决办法可以把ExecStartPre=/bin/sleep 设置的长一点 。 其实这个也是frpc的一个bug,如果能一直间隔几秒重新连接,就没有问题了。(重连的机制可以与正常连接以后的断开机制一样,间隔1秒,2秒,4秒,8秒,16秒,后面一直20秒)
Author
Owner

@Glucy-2 commented on GitHub (Jul 31, 2023):

我也是这个情况,设置了login_fail_exit = true也不会退出,也不会重连,就一直挂在那

<!-- gh-comment-id:1657901305 --> @Glucy-2 commented on GitHub (Jul 31, 2023): 我也是这个情况,设置了`login_fail_exit = true`也不会退出,也不会重连,就一直挂在那
Author
Owner

@gexiaopeng commented on GitHub (Aug 2, 2023):

我也是这个情况,设置了login_fail_exit = true也不会退出,也不会重连,就一直挂在那

按官方描述 login_fail_exit =true是默认设置,启动以后失败一次就退出。 可以设置login_fail_exit=false试一试,这样应该就不会退出。

<!-- gh-comment-id:1661323888 --> @gexiaopeng commented on GitHub (Aug 2, 2023): > 我也是这个情况,设置了`login_fail_exit = true`也不会退出,也不会重连,就一直挂在那 按官方描述 login_fail_exit =true是默认设置,启动以后失败一次就退出。 可以设置login_fail_exit=false试一试,这样应该就不会退出。
Author
Owner

@github-actions[bot] commented on GitHub (Sep 2, 2023):

Issues go stale after 30d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.

<!-- gh-comment-id:1703576194 --> @github-actions[bot] commented on GitHub (Sep 2, 2023): Issues go stale after 30d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.
Author
Owner

@lamhui commented on GitHub (Sep 14, 2023):

遇到相同问题,退回之前版本就正常,看起来是frpc在启动时联网得问题

请问你退回正常的版本号是多少?谢!

<!-- gh-comment-id:1718985584 --> @lamhui commented on GitHub (Sep 14, 2023): > 遇到相同问题,退回之前版本就正常,看起来是frpc在启动时联网得问题 请问你退回正常的版本号是多少?谢!
Author
Owner

@ddddavid-he commented on GitHub (Sep 14, 2023):

遇到相同问题,退回之前版本就正常,看起来是frpc在启动时联网得问题

请问你退回正常的版本号是多少?谢!

大概是0.49和以下吧,按照上面的方法在配置文件加一行就能解决问题了

<!-- gh-comment-id:1719067770 --> @ddddavid-he commented on GitHub (Sep 14, 2023): > > 遇到相同问题,退回之前版本就正常,看起来是frpc在启动时联网得问题 > > 请问你退回正常的版本号是多少?谢! 大概是0.49和以下吧,按照上面的方法在配置文件加一行就能解决问题了
Author
Owner

@IMJacky commented on GitHub (Oct 19, 2023):

同求,老铁们怎么解决的

<!-- gh-comment-id:1769727257 --> @IMJacky commented on GitHub (Oct 19, 2023): 同求,老铁们怎么解决的
Author
Owner

@Glucy-2 commented on GitHub (Oct 19, 2023):

我设置了个5秒的启动延迟就没出现了
或者试试把依赖改成network-online.target

<!-- gh-comment-id:1769728773 --> @Glucy-2 commented on GitHub (Oct 19, 2023): 我设置了个5秒的启动延迟就没出现了 或者试试把依赖改成`network-online.target`
Author
Owner

@IMJacky commented on GitHub (Oct 28, 2023):

我设置了个5秒的启动延迟就没出现了 或者试试把依赖改成network-online.target

After = network.target network-online.target syslog.target
Wants = network.online.target

在官方的实例上面添加 network.online.target 这个方法亲测可行

<!-- gh-comment-id:1783653187 --> @IMJacky commented on GitHub (Oct 28, 2023): > 我设置了个5秒的启动延迟就没出现了 或者试试把依赖改成`network-online.target` `After = network.target network-online.target syslog.target` `Wants = network.online.target` 在官方的实例上面添加 `network.online.target` 这个方法亲测可行
Author
Owner

@sonor-liang commented on GitHub (Nov 20, 2023):

我设置了个5秒的启动延迟就没出现了 或者试试把依赖改成network-online.target

After = network.target network-online.target syslog.target Wants = network.online.target

在官方的实例上面添加 network.online.target 这个方法亲测可行

该方法亲测可行!!!!!!!

<!-- gh-comment-id:1819127197 --> @sonor-liang commented on GitHub (Nov 20, 2023): > > 我设置了个5秒的启动延迟就没出现了 或者试试把依赖改成`network-online.target` > > `After = network.target network-online.target syslog.target` `Wants = network.online.target` > > 在官方的实例上面添加 `network.online.target` 这个方法亲测可行 该方法亲测可行!!!!!!!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#2816
No description provided.