v2ray-core: V2ray 5.1.0 unable to run as a systemd service

What version of V2Ray are you using?

5.1.0

What’s your scenario of using V2Ray?

I have installed a new server, and the script automatically installed v 5.1.0, unable to run v2ray as a service on Debian 10 Server.

What problems have you encountered?

Starting v2ray as a service exits with (code=exited, status=2). Full error is the following Process: 1173 ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json (code=exited, status=2)

The problem is ExecStart. If I run the line /usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json in terminal directly I get the following output: flag provided but not defined: -config Usage of /usr/local/bin/v2ray:

However if I run this /usr/local/bin/v2ray run -c /usr/local/etc/v2ray/config.json then v2ray will run.

So I edited as root /etc/systemd/system/v2ray.service and changed the file to have the following line ExecStart=/usr/local/bin/v2ray run -c /usr/local/etc/v2ray/config.json

I then ran the following systemctl daemon-reload && systemctl restart v2ray

However when I run systemctl status v2ray I get the following output:

● v2ray.service - V2Ray Service
   Loaded: loaded (/etc/systemd/system/v2ray.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/v2ray.service.d
           └─10-donot_touch_single_conf.conf
   Active: failed (Result: exit-code) since Thu 2022-09-08 02:38:45 UTC; 11min ago
     Docs: https://www.v2fly.org/
  Process: 1173 ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json (code=exited, status=2)
 Main PID: 1173 (code=exited, status=2)

Sep 08 02:38:45 ONEVPS220908004518 systemd[1]: v2ray.service: Main process exited, code=exited, status=2/INVALIDARGUM
Sep 08 02:38:45 ONEVPS220908004518 systemd[1]: v2ray.service: Failed with result 'exit-code'.
Sep 08 02:38:45 ONEVPS220908004518 systemd[1]: v2ray.service: Service RestartSec=100ms expired, scheduling restart.
Sep 08 02:38:45 ONEVPS220908004518 systemd[1]: v2ray.service: Scheduled restart job, restart counter is at 5.
Sep 08 02:38:45 ONEVPS220908004518 systemd[1]: Stopped V2Ray Service.
Sep 08 02:38:45 ONEVPS220908004518 systemd[1]: v2ray.service: Start request repeated too quickly.
Sep 08 02:38:45 ONEVPS220908004518 systemd[1]: v2ray.service: Failed with result 'exit-code'.
Sep 08 02:38:45 ONEVPS220908004518 systemd[1]: Failed to start V2Ray Service.

Please note that it is defaulting back to ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json and not accepting my edited ExecStart=/usr/local/bin/v2ray run -c /usr/local/etc/v2ray/config.json

What’s your expectation?

v2ray should run as a service on the server, however unable to as ExeStart is defaulting back to a faulty launch command.

Please attach your configuration here

{ “inbounds”: [{ “sniffing”: { “enabled”: true, “destOverride”: [ “http”, “tls” ] }, “port”: 8388, “listen”: “127.0.0.1”, “protocol”: “vmess”, “settings”: { “clients”: [ { “id”: “4a4a022b-a073-4094-899a-ca04a5c232cd”, “level”: 1, “alterId”: 0, “security”: “auto” } ] }, “streamSettings”: { “network”: “ws”, “wsSettings”: { “path”: “/websocket/” } } }], “outbounds”: [{ “protocol”: “freedom”, “settings”: {} },{ “protocol”: “blackhole”, “settings”: {}, “tag”: “blocked” }], “routing”: { “domainStrategy”: “AsIs”, “rules”: [ { “type”: “field”, “ip”: [“geoip:private”, “geoip:cn”], “outboundTag”: “block”, “protocol”: [“bittorrent”] } ] } }

If V2Ray cannot start up, please attach output from --test command

flag provided but not defined: -config Usage of /usr/local/bin/v2ray:

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

处理方式1: rm -rf /etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf.conf systemctl daemon-reload systemctl restart v2ray 处理方式2: vi /etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf.conf 把ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json 改为ExecStart=/usr/local/bin/v2ray run -config /usr/local/etc/v2ray/config.json systemctl daemon-reload systemctl restart v2ray 处理方式3: 切回老版本: bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --version v4.45.2 就好啦

Hi, I just had the same exit-code error problem. You can get more detailed information about the error by the command journalctl -u v2ray (scroll down to the end!). In my case, it told me the error happened because v2ray couldn’t initial the access.log file, so I deleted that file and this time systemctl start v2ray worked properly. Your problem may be different, but the journalctl was the place I didn’t check for two hours of debugging this problem. And it seems like systemctl status v2ray is not providing much information about the error.

I don’t see anything wrong of the systemd script in the repo, it uses v2ray run -config, which was actually fixed 8 months ago. Download any package for Linux from the release page and you can find it out.

This is the repo for the v2ray itself, not for installation script or third party packages. Nothing here in this repo can install or configure the software for you, instead, it only provides all the necessary files (including the correct systemd script) for you to install. So it’s an issue of the installation script you uses, not v2ray.

Also, there is nothing wrong to introduce break changes in a major version update, on the contrary, that’s exactly what’s a major version update for.

Well I installed from the script install-release.sh downloaded from the v2fly GitHub. I followed official documentation for install and this is the result of how it was setup.

In your output: Process: 1173 ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json (code=exited, status=2)

Your systemd unit is still using a wrong command. You should use v2ray run -config, not v2ray -config

v2fly/fhs-install-v2ray#243

Thank you, I rolled back to v4.45.0 with the command bash install-release.sh --version v4.45.0