A VNC server is already running as :1

124 篇文章 8 订阅

现象

VNC服务使用《Centos7安装和配置VNC服务器 - GNOME篇》https://blog.csdn.net/lxyoucan/article/details/113179208
中的配置方法。
一开始服务都是正常的,在我多次重启vnc服务后就出现异常了,这个:1端口的vnc服务在也启动不了了。搞的我只好使用:2端口开启vnc服务。

启动vncserver时报错:

Warning: localhost.localdomain:1 is taken because of /tmp/.X1-lock
Remove this file if there is no X server localhost.localdomain:1
A VNC server is already running as :1

根据错误信息显示A VNC server is already running as :1,应该是已经运行了:1服务了,实际上查询出来的结果:1并没有正常运行。
测试方法如下:

vncserver -list

TigerVNC server sessions:

X DISPLAY #	PROCESS ID
:2		17617

实测5901端口也没有监听。

ss -tulpn| grep vnc
tcp    LISTEN     0      5         *:5902                  *:*                   users:(("Xvnc",pid=17617,fd=9))
tcp    LISTEN     0      128       *:6002                  *:*                   users:(("Xvnc",pid=17617,fd=6))
tcp    LISTEN     0      5      [::]:5902               [::]:*                   users:(("Xvnc",pid=17617,fd=10))
tcp    LISTEN     0      128    [::]:6002               [::]:*                   users:(("Xvnc",pid=17617,fd=5))

失败的尝试

  • 删除所有vnc相关的进程,重启服务。结果还是失败!

我猜测重启系统大法应该可以解决,但是由于服务器是半生产环境,重启可能会影响一部分人使用。所以没有试。

解决办法

删除/tmp/.X1-lock文件。

rm /tmp/.X1-lock
rm /tmp/.X11-unix/X1

删除完成这两个文件后,重启服务,成功启动了。

  • 5
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
To install and set up VNC server on Ubuntu, you can follow these steps: 1. Update your system's package list: ``` sudo apt update ``` 2. Install a desktop environment (if you haven't already): ``` sudo apt install ubuntu-desktop ``` 3. Install the VNC server software (TightVNC): ``` sudo apt install tightvncserver ``` 4. Run the VNC server setup: ``` tightvncserver ``` During the first run, it will prompt you to set a password for VNC access. Choose a strong password and remember it. 5. Stop the VNC server: ``` tightvncserver -kill :1 ``` 6. Configure the server to start at boot: ``` sudo nano /etc/systemd/system/vncserver@.service ``` Add the following content to the file and save it: ``` [Unit] Description=VNC Server at %i After=syslog.target network.target [Service] Type=forking User=<YOUR_USERNAME> PAMName=login PIDFile=/home/%u/.vnc/%H%i.pid ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1 ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i ExecStop=/usr/bin/vncserver -kill :%i [Install] WantedBy=multi-user.target ``` Replace `<YOUR_USERNAME>` with your actual username. 7. Enable and start the VNC server service: ``` sudo systemctl enable vncserver@1.service sudo systemctl start vncserver@1.service ``` You can replace `1` with the display number you want to use. After completing these steps, you should be able to connect to your Ubuntu machine using a VNC client using the IP address or hostname of the server, followed by the display number (e.g., `192.168.1.100:1`).

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值