Introduction: Setting Up a VNC Server on Your Raspberry Pi

If your Raspberry Pi is purposed to do a task that normally does not require a monitor, mouse and keyboard (or any human interaction for that matter), sometimes it is useful to access your Raspberry Pi's operating system without having to connect a monitor, mouse and keyboard. Here's how

Step 1: Required Materials

You will need the following:
- Raspberry Pi Model B (ModelA will also work in this case)
- Ethernet cable or wifi dongle (this one works well and is inexpensive: http://www.adafruit.com/products/814 
- Standard USB to micro USB cable (most Android smart phones come with one)
- Monitor, mouse and Keyboard for initial setup
- USB hub if you want to connect more than 2 things (in this case Mouse+Keyboard+Wifi Dongle)



Step 2: Installing a VNC Server on Your Raspberry Pi

This instructable will assume that you have already gotten Raspbian or some operating system installed. (Raspbian was used for this instructable)

If you have not yet installed an operating system, a common, well documented stable one is Raspbian which can be installed by using NOOBS (New-out-of-box-software). Once you download it to an SD card, it pretty much will install itself. It makes setting up the Raspberry Pi - which will from now on be affectionately referred to as Pi - VERY easy!

Once you have an operating system running here are the required steps to install a VNC server:

1. Open LX terminal
2. In LX terminal type in "sudo apt-get update" to update the operating system to the latest version
3. When prompted to update type in "y" and press enter
4. After updating is complete type in "sudo install tightvncserver". Press "y" and hit enter when prompted
5. Once tight VNC server has completed installation you can start it by typing in "vncserver:1"
6. It will prompt you to create a password. Keep in mind passwords can be at MOST 8 characters long.
7. Once you have entered a password you are done! The VNC server is now running in the background of your Raspberry Pi's      operating system. Now you can use any computer on your network with a VNC client to remotely access the Raspberry Pi

Step 3: Installing a VNC Client on Your Windows PC

This only covers how to install a client on a Windows PC. There are several free clients available. In this one we will use Ultra VNC, but here's a list of VNC clients that offer free versions:

- Tight VNC
- Real VNC
- Ultra VNC 

Once you  have installed one of those VNC clietns/viewers, you will need to figure out what the IP address of your Raspberry Pi is. You can do this by opening LX Terminal and typing in "sudo if config"

Once you know your Raspberry Pi's IP address (shown in red box in picture below), then go to your Windows machine and open up your VNC client. Type in your Pi's IP address followed by ":1" Then enter your password and voila! You are now remotely accessing your Raspberry Pi's operating system. 


Step 4: Setting Up the Pi to Automatically Start a VNC Server Upon Bootup

Now that you have the ability to VNC into your Pi, you will likely never want to hook it up to a monitor, mouse and keyboard again. But what happens when you lose power to the Pi, or when you restart it? Will you have to hook up a monitor and keyboard every time to start the VNC server again? Of course not! Here's how to setup your Pi, so that you never have to hook up another keyboard and mouse to it again.

1. Setup the Pi to boot into the graphical user Interface (this is the actual desktop environment that you interact with) automatically at start-up. Do this by opening LX Terminal and typing in "sudo ipconfig"
2. Select "Enable Boot to Desktop"
3. Select "Desktop" and press "OK"
4. Select "Finish" to exit and save the changes made
5. go back to LX Terminal and type in "cd /home/pi". This will take you the home/pi directory, obviously.
6. go into the hidden config directory by typing "cd .config"
7. create a new folder named "autostart" within the ".config" folder by typing "sudo mkdir autostart"
8. enter into the folder you just created by typing "cd autostart"
9. create a new configuration file that will tell the OS to start VNC upon bootup by typing "sudo nano tightvnc.desktop"
10. This will open the text editor within LX Terminal. Enter in the following into the text file:
           [Desktop Entry]
           Type=Application
           Name=TightVNC
           Exec=vncserver:1
           StartupNotify=false
11. Press Ctrl+O to write the changes and Ctrl+X to exit the text editor. your Pi will automatically start the VNC server every time it boots up!
12. Figure out what to do with the extra monitor, mouse and keyboard you just free'd up.


I made it at Techshop: www.techshop.ws

Comments

author
shashankG35 (author)2017-07-14

This part in step 3 at the end

"""Once you know your Raspberry Pi's IP address (shown in red box in picture below), then go to your Windows machine and open up your VNC client. Type in your Pi's IP address followed by ":1" Then enter your password and voila! You are now remotely accessing your Raspberry Pi's operating system""""

when i type in the password , the prompt comes up as authentication failed

author
DragonFruitBOSS (author)2016-02-25

btw it is "sudo apt-get install tightvncserver"

author

thanks!

author

Thanks! I was struggling but this helped

author
mal-hd (author)2014-12-07

I do as in the steps

but when i tried to make a connection

I have a msg on my computer

indicates that the "target machine refused actively"

author
kirtiksoni (author)mal-hd2015-01-17

When you enter the ip address on vncviewer, you have to enter the server also. example 192.xxx.x.x and then enter :1 or :2 etc to it. Hope it helps!

author
3030tank (author)kirtiksoni2017-02-08

huge help. I think many people missed this important step. Thanks!

author
PospaPunk made it! (author)2016-07-22

Thank you very much. This is really very simple and working manual. My cheap USB hub (for 1 dollar from eBay) has only 2 ports, that works. Now its great. An it even works for BrickPi image.

screenshot_inst_done.png
author
AhmedH134 (author)2016-03-01

sudo apt-get install tightvncserver

Reading package lists... Done

Building dependency tree

Reading state information... Done

tightvncserver is already the newest version.

The following packages were automatically installed and are no longer required:

gnome-desktop3-data gnome-icon-theme-symbolic libavahi-gobject0 libcwiid1

libgnome-desktop-3-2 libnss3 libqscintilla2-8 libruby1.9.1 libsclang1

libscsynth1 libwnck-3-0 libwnck-3-common libyaml-0-2 ruby1.9.1

squeak-plugins-scratch squeak-vm

Use 'apt-get autoremove' to remove them.

0 upgraded, 0 newly installed, 0 to remove and 72 not upgraded.

author
jonpurchase (author)2016-01-29

Found the answer myself - X11vnc gives exactly the same view as if plugged into monitor. Use x11vnc instead of tightvnc if you want to mirror the display instead of starting a new session each time.

author
jonpurchase (author)2016-01-29

Having problems with sessions. I have a webpage displayed on my pi and have set up VNC but when I VNC into my pi it shows a fresh session and not the active one????

author
hgosalia made it! (author)2015-11-29

success, worked like a charm!

raspberry_pi_vnc.png
author
hgosalia made it! (author)hgosalia2015-11-29

...and capable of controlling through the iPhone!

IMG_2776.PNG
author
KurtH3 made it! (author)2015-09-21

I did it and found out I can access my Pi from multiple devices at the same time!

FWRXAE1IDON7SAJ.jpeg
author
Fastcash (author)KurtH32015-10-29

Hi,

Can you explain how you do that?

I follow this tutorial and it worked correctly.

Then, I tried to do it by adding a second .desktop file similar to the first one, but at each startup, one random of the two VNC Viewer displays only a grey screen.

author
kaneda26 (author)2015-09-28

Also, "vncserver:1" doesn't work.

author
kaneda26 (author)2015-09-28

Step 4 should read "sudo apt-get install tightvncserver"

author
AlmostNotDumb (author)2015-08-09

It's not auto booting at startup. At the end of step 4 when you enter the text it says to press Ctrl+O to write the changes then Ctrl+X to exit. After I press Ctrl+O it gives me other options non of which are exiting.

It gives me these options: ^G (Get Help), ^C (Cancel), M-D (DOS Format), M-M (Mac Format), M-A (Append), M-P (Prepend), M-B (Backup File)

What do I do from here? I am assuming my problem for my vncserver not starting is this since it is the only part of this tutorial that was not completely covered.

author
jujuink (author)2015-02-09

Keep in mind when you go to do step 5...

5. Once tight VNC server has completed installation you can start it by typing in "vncserver:1" that it should be "vncserver :1" The space between the r and the : is important.

author
MakinThings (author)jujuink2015-06-10

also, using raspbian, installing tightvnc needs to go "sudo apt-get install"

author
YafeatA (author)2014-11-10

Just to be on the good side its sudo apt-get install not sudo install

author
decri (author)2014-08-20

Thanks for this instructables, I only wanted to know how to change resolution :)

author
MartinP2 (author)decri2014-08-22

By adding the the -geometry flag after "vncserver: 1"you can set resolution, with the -depth flag the color depth

E.g. Exec=vncserver :1 -geometry 1920x1080 -depth 24

author
digitalvapor (author)2014-07-15

Be sure to put space before `:1`. That is, `Exec=vncserver :1`, and of course `sudo raspi-config` instead of `ipconfig` ;)

Cheers, Tom

About This Instructable

337,633views

172favorites

License:

More by knn002:Setting up a VNC Server on your Raspberry Pi
Add instructable to: