Raspberry Pi VNC fail connection - raspberry-pi

I face a problem that I can ping to correct IP address, it have no loss. And also I use nmap ping the pi address, and I get it correctly. Then I using VNC viewer to try access to pi, but it always show up "The connection was refused by the host computer"
Did u all have any idea ?

Your problem indicates that your Raspberry Pi was reached by the connection attempt, but that no service was running on the relevant port and hence the connection was refused. I think, this is because the VNC service is not running on your Raspberry Pi.
Update 1
Raspbian now comes with the server by default thanks to a partnership with RealVNC, it just needs to be enabled.
Original
You must enable VNC Server on your Raspberry Pi using terminal
sudo apt-get update
sudo apt-get install realvnc-vnc-server
or you can also enable VNC Server on the command line using the sudo raspi-config command.
Advanced Options->VNC:Yes
Now you can connect to the VNC Server using a application such as VNC Viewer.

I have been having this issue with my Raspberry Pi Zero W even though it worked perfectly beforehand. This page https://www.realvnc.com/en/connect/docs/raspberry-pi.html should help.
I ran vncserver in a ssh window after verifying the interface settings in raspi-config.
It started the VNC Server and gave me the VNC Server catchphrase and the IP address with Port Number as shown in the photo linked below.
vncserver output
After running that command I was able to get the VNC Viewer on my windows machine to connect to the pi.
I then ran sudo systemctl enable vncserver-x11-serviced.service in the ssh window so that it would start automatically on subsequent reboots.

I've had this same problem but found a different reason. I found three ways to get around this error message.
Plug a mouse or keyboard into the Raspberry Pi zero, waking up the screen and the VNC connection.
Wait about 5 - 10 minutes which is the amount of time for the screen saver to kick in which seems to wake up VNC connection. but don't wait to long other wise run this command to get things going via ssh "systemctl start vncserver-x11-serviced.service".
I am hoping the new update they just published will fix this problem. I don't see this as much with the Raspi B3+ as with the Zero H.
The last was plug in both monitor and mouse and that for sure fixes the VNC issues but defeats the headless connection. It seems that running headless and the screen/saver are somehow related but just not smart enough to figure it out.

For people using newer version of Raspberry, VNC option is found under:
Config>Interface Options

pinging to any service will only tells us that whether the server is currently listening on that port or not. It will not tell you the possible result to connection request asked by client.
It seems that, you have installed VNC server but not started it properly. Use this command to start it...
# vncserver start
Also recheck the port number is correct or not.

With the Rasp Pi 4 - had connecting fail after rebooting both the server and client (both Rasp Pi 4s).
Took a while to realize that I have two clients: One named "VNC Client", the other "VNC Viewer for Google Chrome".
The former works, the latter doesn't.

Related

Can't guess default raspberry password

I've been trying to establish ssh connection with my raspberry by adding config files (wpa_supplicant.conf, ssh) to boot section of sd card with raspberry OS. I've done everything right and usually after these steps I could easily connect to my raspberry.
But, now I can't do this.
Whenever I try to log into raspberry using 'pi' as login and 'raspberry' as password, it says that this is incorrect password. I tried reinstalling OS on sd card; however, it didn't help.
I don't have any other opportunities other than connecting to raspberry wirelessly.
I have Raspberry Pi 4B and Raspberry OS 64-bit
It seems that you are using the latest release of raspbian. Developers have made a huge step forward to the security and there is no more default user pi and password raspberry, no need of the wpa_supplicant.conf & ssh files (but they are still work).
For headless setup you can press settings button in the last version of Raspberry Pi Imager and configure User, Wi-Fi, SSH and so on.
Scroll down to the Headless setup chapter
https://www.raspberrypi.com/news/raspberry-pi-bullseye-update-april-2022/
I created a guide with images to do this here:
As per the official raspberry blog at https://www.raspberrypi.com/news/raspberry-pi-bullseye-update-april-2022 the default username password will no longer be allowed for headless login.
Basically there are two methods
Use the updated raspberry pi imager too from here
manually add userconf file in the boot directory with username:encrypted-password as a single line. to generate encrypted-password string use echo 'mypassword' | openssl passwd -6 -stdin tested on win 10

VSCode remote debugging on NextCloudPi not working because SSH connection failed

Not really a question but already the answer. Just to save others from spending days on this task.
What I want to do
I want to extend the basic NextCloudPi image with some custom websites including PHP. For ease use of remote debugging I am using VSCode and Xdebug.
The Problem was
I can't get a SSH connection to my raspi from VSCode and therefore also PHP debugging didn't work. SSH connection to the raspi worked well with other tools (putty, PowerShell etc.). Also Xdebug was set properly on the raspi (according to phpinfo();). In the log of the ssh-plugin of VSCode the following error appeared:
Failed to set up socket for dynamic port forward to remote port 37399: Socket closed. Is the remote port correct?
Relevant Versions
NextCloudPi 1.36.3
Xdebug 3.0.4
VSCode 1.60.2 (RemoteSSH 0.65.8, PhpDebug 1.19.0)
The Solution is
After spending evenings of googling I found out that the TCP port forwarding of the raspi's SSH service has to be enabled which is not in the basic nextcloudpi-image. This thread gave me the final clue: VSCode Remote SSH Connection Failed
So just set in /etc/ssh/sshd_config AllowTcpForwarding to yes and everything should work as easy as described in all the manuals.

Running Pianobar on a headless Ubuntu 18.04 server (without X11) with Alsa/Pulseaudio and streaming audio over SSH to a Mac laptop

There seem to be a vast amount of articles/posts on setting up Pulseaudio and SSH but I don't know if I've seen any in regards to pianobar.
My scenario:
I am running a headless Ubuntu 18.04 server WITHOUT X11. I would like to ssh to it from my laptop and run the pianobar app so the sound comes out of my laptop.
What I have working:
On the Ubuntu server I have installed Alsa and all its tools
On the Ubuntu server I have installed pianobar
When I physically sit at the Ubuntu server, login, and run pianobar I get sound
What I have attempted:
I installed Pulseaudio and configured the /etc/pulse/default.pa file as instructed in a lot of the google info I find. The most important part seems to be:
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.0.0/24 auth-anonymous=1
My problem:
When I ssh into the server from my Mac and run pianobar the sound is still coming out of the server
I have tried a lot of variations with my ssh connection. I understand I'm supposed to be forwarding a port of some sort but I dont know if I have even setup the server right.
Docs I have used to troubleshoot:
https://askubuntu.com/questions/28176/how-do-i-run-pulseaudio-in-a-headless-server-installation?rq=1
https://github.com/cladmi/systemd_pulseaudio_al
https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Network/
https://askubuntu.com/questions/28176/how-do-i-run-pulseaudio-in-a-headless-server-installation
https://askubuntu.com/questions/939144/playing-audio-stops-in-unity-when-i-switch-user/939338#939338

port forwarding in raspberry pi on debian

I want to forward incomings from 192.168.1.50:5007 to 10.1.1.117:5007 on raspberry pi debian installed . I do not want to make a bridge between two networks. How can I achieve this?
You can use ssh:
ssh -L 192.168.1.50:5007:10.1.1.117:5007 -N localhost
this assumes that your server is the machine at 192.168.1.50. if not, you're going to need to give me the IPs of all the machines involved and tell me which is which.
You'll need sshd running but you should already have that with Raspbian.
After you run it, you'll need to authenticate. No forwarding will occur until then.
Once you've logged in, it will look like it's hung, but it's not; it just doesn't have any output to show you.
At this point the forwarding is active.
You can kill it with ctrl-c when you're done.
If you'd rather keep it running in the background instead of having an empty window sitting around, you can use ctrl-z (which will pause its execution) followed by bg which will resume the process in the background.
To stop the forwarding from a backgrounded job, you're going to have to find the pid in ps and kill it.
Run netstat -ano --tcp |grep 5007 to see your server listening for connections on 192.168.1.50:5007, remote computers making connections to 192.168.1.50:5007, and new connections from your server to 10.1.1.117:5007

How can I get connection with Raspberry without access of its shell?

There are Raspberry Pi 3 model B and MicroSD with NOOBS OS. Unfortunately I have not any display to get a direct access to NOOBS shell. So remote connection could be set via ssh. However my device does not have any IP-address. I read everywhere that the connection options must be set... via shell. But it's impossible for me!
How can I resolve this problem and get remote access to shell (or to desktop even)?
I ran into this a while ago, I started using PiBakery. It will write raspbian to the SD card and add a startup script to connect to the network and enable ssh. This way the first time you boot it up, its ready to go and you can connect via SSH.
When you set it up, it also allows you to set a static IP address so you know exactly where it is when it boots.
Enable SSH by placing a file named 'ssh', without any extension, onto the boot partition of the SD card.
Connect your device to your LAN using a wired connection.
From another computer on the network execute arp -a to view locally connected hosts and get your raspberry pi's IP address.
From there you should be able to SSH into your pi.