For my headless elementary machines, I tend to set up the VNC server via LightDM. It requires the
tigervnc server to be installed. You can configure it as follows:
sudo vncpasswd /etc/vncpasswd
/etc/lightdm/lightdm.conf with the following contents:
command=Xvnc -rfbauth /etc/vncpasswd
Then restart the machine or restart lightdm, which will kill your session. VNC should then be listening on the port specified in the config file and you will be presented with the elementary greeter when you connect. Logging into the machine locally will log you out of your VNC session and vice versa.