Troubleshoot Refused VNC Connection in CentOS 7

來源:互聯網
上載者:User

標籤:

Troubleshoot Refused VNC Connection in CentOS 7Posted on March 15, 2015 by Istvan Szarka — 2 Comments

The other day I connected to my CentOS 7 computer from Windows via RealVNC Viewer. Everything went fine, but after I left the machines unattended for a short time, the connection froze to the point that I had to shut CentOS down and boot it again. When I tried to connect again, I got an error message saying something like “The connection was refused by the host computer” or similar, I can’t remember exactly. I rebooted CentOS several times, but nothing changed. Now I had to connect a monitor and the necessary peripherals to the box and start troubleshooting.

First, I checked the status of the VNC service:

[[email protected] Desktop]# systemctl status [email protected]:2.service -l[email protected]:2.service - Remote desktop service (VNC)   Loaded: loaded (/etc/systemd/system/[email protected]:2.service; enabled)   Active: failed (Result: exit-code) since Sat 2015-02-28 14:37:00 CET; 10min agoFeb 28 14:37:00 localhost.localdomain systemd[1]: [email protected]:2.service: control process exited, code=exited status=2Feb 28 14:37:00 localhost.localdomain systemd[1]: Failed to start Remote desktop service (VNC).Feb 28 14:37:00 localhost.localdomain systemd[1]: Unit [email protected]:2.service entered failed state.

The VNC service apparently failed to start. If you don’t know why I used [email protected]:2.service, please read my earlier post about configuring VNC. I tried to start the service, but it kept failing:

[[email protected] Desktop]# systemctl start [email protected]:2.serviceJob for [email protected]:2.service failed. See ‘systemctl status [email protected]:2.service‘ and ‘journalctl -xn‘ for details.

As I was digging through the internet, I found some clues about corrupted session files that had to be deleted to solve this problem. The files were supposed to be in the /tmp/.X11-unix directory (capital X11, Linux is case-sensitive!). When I checked the contents of /tmp, I found this:

There was no /.X11-unix directory inside. The issue was, that this folder is hidden and such items can only be seen if you put -la after ls, like this:

Now I saw the folder I was looking for at the end of the list. Inside /.X11-unix were the session files:

The corrupted file belonging to “vncuser”, the user I configured for VNC access, was X2. I removed it with the rm /tmp/.X11-unix/X2 command. Then, I started the service, rebooted the computer and I was able to seamlessly connect to my CentOS machine through VNC.

Troubleshoot Refused VNC Connection in CentOS 7

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.