22

I'm seeing the login screen every time my pi boots up. At first it didn't need any password but after 3-4 boots, pi asks for a password. When I write the password displays the same screen again. I don't know what to do now :/

I'm using Raspbian on Raspberry Pi 3. Haven't installed tightvncserver as I saw other questions here. Screenshot of the screen below.

screenshot

I tried logging in from command line. I press Ctrl+Alt+F6 to get into command line and login from there.

After login I write startx, the screen turns black, and then it's showing the error:

xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: server error
8
  • I assuming this is the login screen for VNC? The password will be whatever you set it. The default password for a Raspberry Pi is raspberry.
    – Darth Vader
    Apr 16, 2016 at 16:02
  • Haven't installed vnc
    – arslion
    Apr 16, 2016 at 16:04
  • did you try raspberry as the password?
    – Darth Vader
    Apr 16, 2016 at 16:07
  • Yes i tried it works on command line but didn't works here on this screen.
    – arslion
    Apr 16, 2016 at 16:09
  • 1
    I'm stuck here as well. The GUI login works (in that if you type an incorrect user or pw, it says so) but then loops back around to give you the same login over and over.
    – JoshP
    May 19, 2016 at 15:55

8 Answers 8

23

It looks like your X server is working fine, but either your login manager or your desktop environment are failing to run properly (the former is supposed to ask for a password, then start the latter for you).

How to investigate

Since you can login via command line, you can easily access important log files which you should check for error messages. Login manager (I assume lightdm) logs usually live in /var/log/lightdm/, desktop environments should also keep their log somewhere in /var/log/. Check man to find out.

Also try starting your desktop environment manually from command line (e.g. if you use LXDE run startlxde) and check the output for eventual error messages.

How to fix

Without knowing what exactly the problem is, here are some actions which might help:

  • reset permissions on your home folder: sudo chown -R pi /home/pi. (Specifically, the .Xauthority file may have the incorrect permissions. In this case, you may only need sudo chown pi:pi .Xauthority to correct the issue.)
  • reinstall your login manager and desktop environment. Use dpkg --purge to remove packages completely, including configuration files (you might want to back up files you have modified), then reinstall the packages back.
4
  • 3
    It was totally the xauthority problem for me, good call. Oct 5, 2018 at 20:34
  • Thank you so much Dmitry and squareskittles! I was pulling my hair out trying before I found this solution. May 9, 2019 at 18:05
  • Not enough points for my own answer; but this one helped me. I couldn't find much of use in the logs, but remembered I had uninstalled Python yesterday (trying to reduce the footprint). Do not remove Python. A reinstall of lxsession did the trick in the end.
    – Grim
    Jul 29, 2020 at 15:26
  • 1
    @Grim Python (along with Perl and Bash) is one of those scripting languages any sane Linux system is expected to have. A lot of packages don't list Python as a dependency while relying on Python scripts. Jul 29, 2020 at 21:47
5

I got the exact same problem just now. It seems to relate to .Xauthority file. I just removed this file in the home folder by:

sudo rm /home/pi/.Xauthority

Now it's back to normal

2
  • I'd made a .xsession file in my home directory (when playing with xrdp) and removing that fixed it.
    – KERR
    Mar 10, 2018 at 23:07
  • I was getting a black screen flash and sent back to the log in screen after correctly entering the password. I know it was correct, because if I entered the password wrong I was given a message that the password was incorrect. Running this command solved my issue and I am logging in no problem again. Raspberry Pi OS Kernel version: 5.4
    – TurboGus
    Dec 18, 2020 at 3:35
3

Solution 1:

Insert the microSD card to some linux PC and clean some files. Lack of free drive space might cause this.

Solution 2:

While you see the login screen, press Ctrl+Alt+F1. This will bring the console. There you can type:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
reboot

These methods worked for me when I had this problem. Good luck.

0

I don't know if this will help and would appreciate feedback if there are any significant issues with my solution.

I had this problem and discovered that the shell being started to bring up the desktop (/bin/sh) is really just a symbolic link to dash (/bin/dash). I don't recall the details, but figured out that I had things in my .profile that were incompatible with dash and was causing the startup to fail.

The desktop had been working fine before I did an update, so I assume the update changed the link?

In any case, using putty on my PC to login via ssh I was able to delete the link to dash and created sh as a link to bash.

sudo rm /bin/sh
sudo ln -s /bin/bash /bin/sh

I rebooted the pi and everything worked again.

0

In my case this was caused by upgrading OpenSSL to the 1.0.2 developer version, as outlined in the docs for setting up AWS Greengrass. Skipping that step prevented the login loop.

https://docs.aws.amazon.com/greengrass/latest/developerguide/prepare-raspi.html

-1
  1. Use CtrlAltF6 to switch to a virtual console with a text login (if that doesn't work, try the same thing with F1-F5).
  2. Login user=pi pass=raspberry
  3. Try startx to launch a GUI.
2
  • Try sudo startx to GUI.
    – chutchai
    Nov 16, 2016 at 1:41
  • I don't have a startx ?
    – mckenzm
    Oct 1, 2017 at 9:17
-2

1 conect with ssh

ssh you_raspi_ip

user pi
password raspberry

cd ~
rm -R .xsession
sudo reboot
-2

This is sort of a combination of the other two answers:

  1. Use CtrlAltF6 to switch to a virtual console with a text login (if that doesn't work, try the same thing with F1-F5).
  2. Login user=pi pass=raspberry
  3. Use sudo chown -R pi.pi /home/pi. This will set the permissions correctly on any temporary files necessary for the GUI, etc.
1

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