1

I have followed all the steps described in https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-remote-access-for-the-gnome-desktop-on-centos-7

I am able to start the vncserver service

[root@server ~]# systemctl start vncserver@:1.service
[root@server ~]# systemctl status vncserver@:1.service
● vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2016-11-12 01:40:25 EET; 5s ago
  Process: 32470 ExecStop=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
  Process: 3023 ExecStart=/usr/sbin/runuser -l user -c /usr/bin/vncserver %i -geometry 1280x1024 (code=exited, status=0/SUCCESS)
  Process: 3004 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
 Main PID: 3070 (Xvnc)
   CGroup: /system.slice/system-vncserver.slice/vncserver@:1.service
           ‣ 3070 /usr/bin/Xvnc :1 -desktop server:1 (user) -auth /home/user/.Xauthority -geometry 1280x1024 -rfbwait 30000 -rfbauth /home/user/.vnc...

Nov 12 01:40:22 server systemd[1]: Starting Remote desktop service (VNC)...
Nov 12 01:40:25 server systemd[1]: Started Remote desktop service (VNC).

I deleted all iptables rules

[root@server ~]# iptables -nvL
Chain INPUT (policy ACCEPT 2710 packets, 297K bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 2515 packets, 478K bytes)
 pkts bytes target     prot opt in     out     source               destination

Firewall is disabled

[root@server ~]# firewall-cmd --state
not running

Port 5901 is open and listening

[root@server ~]# netstat -tpln | grep "5901"
tcp        0      0 0.0.0.0:5901            0.0.0.0:*               LISTEN      3070/Xvnc
tcp6       0      0 :::5901                 :::*                    LISTEN      3070/Xvnc

I also have the socket file /tmp/.X11-unix/X1

But when I try to connect through vncviewer using IP:5901 I get the same error "The connection was refused by the host computer".

I have multiple servers running this same configuration and everything works fine but all of them were configured after installation, unlike this one which has been running for quite some time. The server is running CentOS 7. Is there anything I can do without physical access to it (no wiping all data/reinstalling the OS) in order to make it work?

  • @icarus I tried with telnet and I also get connection refused – M B Nov 12 '16 at 7:35
  • @icarus Thanks for the help, I completely forgot that the server was behind a router... which didn't forward port 5901 to it. Adding a port forward rule for the router fixed it. – M B Nov 12 '16 at 13:18
1

Ensure that you can connect from the server itself to port 5901 using 127.0.0.1. You can use programs like telnet 127.0.0.1 5901 or socat stdin tcp:127.0.0.1:5901 to do this if you don't have a display on the server.

Ensure that there is nothing in the network filtering the traffic to port 5901.

2

It worked for me after modifying the firewall:

sudo systemctl daemon-reload
sudo firewall-cmd --permanent --zone=public --add-port=5901/tcp
sudo firewall-cmd --reload

Note that the port number is 5901 in my case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.