0

I want to set up a VNC connection between my computer and my mobile phone. I created a Wi-Fi hotspot on the computer and I connected my phone to this Wi-Fi network. I set up a VNC server on the computer, using tigervnc. I checked and it is running:

_$ sudo systemctl status vncserver@1.service
● vncserver@1.service - Remote desktop service (VNC)
   Loaded: loaded (/etc/systemd/system/vncserver@.service; enabled; vendor prese
   Active: active (running) since Wed 2019-08-07 18:27:15 CEST; 2h 41min ago
 Main PID: 10463 (vncserver)
    Tasks: 0 (limit: 4915)
   Memory: 904.0K
   CGroup: /system.slice/system-vncserver.slice/vncserver@1.service
       ‣ 10463 /usr/bin/perl /usr/bin/vncserver :1 -geometry 1440x900 -alway_

I also checked port 5901:

_$ nmap localhost
Starting Nmap 7.70 ( https://nmap.org ) at 2019-08-07 18:43 CEST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00049s latency).
Not shown: 998 closed ports
PORT     STATE SERVICE
631/tcp  open  ipp
5901/tcp open  vnc-1_

On the mobile phone I installed a VNC client. I did not set up ssh. I tried to connect it to the server with the address localhost:5901. But to no avail; I see this message:

"The port on which the computer is listening for a connection could not be contacted."

I have no idea why I can't connect. The Ubuntu server does not run a firewall.

This is the outcome of "sudo iptables-save"

$ sudo iptables-save  
 # Generated by iptables-save v1.6.1 on Wed Aug  7 22:52:46 2019  
*filter  
:INPUT ACCEPT [6569:5209874]  
:FORWARD ACCEPT [0:0]  
:OUTPUT ACCEPT [5441:510108]  
-A INPUT -i wlp3s0 -p udp -m udp --dport 67 -j ACCEPT  
-A INPUT -i wlp3s0 -p tcp -m tcp --dport 67 -j ACCEPT  
-A INPUT -i wlp3s0 -p udp -m udp --dport 53 -j ACCEPT  
-A INPUT -i wlp3s0 -p tcp -m tcp --dport 53 -j ACCEPT  
-A FORWARD -d 10.42.0.0/24 -o wlp3s0 -m state --state RELATED,ESTABLISHED -j ACCEPT  
-A FORWARD -s 10.42.0.0/24 -i wlp3s0 -j ACCEPT  
-A FORWARD -i wlp3s0 -o wlp3s0 -j ACCEPT  
-A FORWARD -o wlp3s0 -j REJECT --reject-with icmp-port-unreachable  
-A FORWARD -i wlp3s0 -j REJECT --reject-with icmp-port-unreachable  
COMMIT  
 # Completed on Wed Aug  7 22:52:46 2019  
 # Generated by iptables-save v1.6.1 on Wed Aug  7 22:52:46 2019  
*nat  
:PREROUTING ACCEPT [215:28223]  
:INPUT ACCEPT [160:24399]  
:OUTPUT ACCEPT [677:49578]  
:POSTROUTING ACCEPT [643:47493]  
-A POSTROUTING -s 10.42.0.0/24 ! -d 10.42.0.0/24 -j MASQUERADE  
COMMIT  
 # Completed on Wed Aug  7 22:52:46 2019  
9
  • Did you connect with localhost:5001 on your phone or on the computer? – NerdOfLinux Aug 7 '19 at 19:48
  • The vnc server is installed on the Ubuntu computer. The VNC client is on the phone; The vnc-client asks the address of VNC-server I want to connect to. So I typed "localhost:5901" on the phone. – peter Aug 7 '19 at 19:55
  • For the VNC client, what did you put for the server address? – NerdOfLinux Aug 7 '19 at 19:56
  • VNC client: localhost:5901 – peter Aug 7 '19 at 20:02
  • Can you add the output of sudo fuser 5901/tcp and sudo iptables-save? – NerdOfLinux Aug 7 '19 at 20:35
0

You have to use the server's address, and not localhost on the client. You can find the server's internal IP address by running

hostname -I

If there is more than one IP address, try all of them.

1
  • I tried that, but it didn't work. – peter Aug 7 '19 at 20:24

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.