Troubleshoot Refused VNC Connection in CentOS 7

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:

[root@localhost Desktop]# systemctl status vncserver@:2.service -l
vncserver@:2.service - Remote desktop service (VNC)
Loaded: loaded (/etc/systemd/system/vncserver@:2.service; enabled)
Active: failed (Result: exit-code) since Sat 2015-02-28 14:37:00 CET; 10min ago Feb 28 14:37:00 localhost.localdomain systemd[1]: vncserver@:2.service: control process exited, code=exited status=2
Feb 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 vncserver@:2.service entered failed state.

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

[root@localhost Desktop]# systemctl start vncserver@:2.service
Job for vncserver@:2.service failed. See 'systemctl status vncserver@: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.

最新文章

  1. java 面试每日一题2
  2. MSBuild和Jenkins搭建持续集成环境
  3. http://www.jobui.com/mianshiti/it/java/6782/
  4. Codevs 1083 Cantor表
  5. COALESCE在SQL拼接中的大用途
  6. C# Winform 拖放操作
  7. 【转载】ACM总结——dp专辑
  8. JDBC基本知识
  9. OpenStack JEOS 镜像
  10. mex (离散化+线段树)
  11. JavaScript 将两个数组合并,且删除重复的值
  12. Spring中实现多数据源事务管理
  13. MySql 数据库移植记录
  14. opencv3.2.0形态学滤波之腐蚀
  15. Codeforces Round #102 (Div. 1) A. Help Farmer 暴力分解
  16. Oracle 和 MySQL的区别(不完整)
  17. helm 安装 spinnaker
  18. jQuery中的$.grep()使用
  19. 前端css小米导航栏设置及盒子定位居中问题
  20. C语言之一般树

热门文章

  1. 使用DotNetOpenAuth搭建OAuth2.0授权框架——Demo代码简单说明
  2. 浅谈session/cookie
  3. 使用View为Data Source的Form开发要点
  4. 关于php Hash算法的一些整理总结
  5. JStorm第一个程序WordCount详解
  6. I/O阻塞非阻塞,同步异步
  7. jquery validate ajax submit form
  8. 红星美凯龙CEO车建新的圆融和霸气
  9. jquery mobile开发笔记之Ajax提交数据(转)
  10. fastjson基本使用 (待大量完善)