startkde $DISPLAY is not set or cannot connect to the X server


if you are not be able to login and you are stuck in kdm lightdm sddm window this can be helpfull for you :

there are a lots of issues that can develop this situation in your machine so i will list them here :

these are really funny but i had even these situations 😀

-no space left in /var

-no space left in /

-no space left in /home

-no plasma-desktop or plasmashell installed

these instead are really normal

-bad video driver installed

-bad xorg manually configurated

-bad init file

i guess these are the most frequent issues so let’s try to find out which one is your issue, if you are skilled you could just read this 

fgrep '(EE)' /var/log/Xorg.0.log

but if you are not a skilled user… 🙂 we will start with some weird errors l 

FIRST STEP PREPARE THE TERMINAL TO TEST YOUR MACHINE

Try to start another terminal session being freezed on kdm window pressing these keys : (NOTE TO GET BACK CTRL ALT F7 it’s the normal session … so if you need to go back just do that.)

CTRL ALT F4

 
Now you have to login with your password after that :

CHECK IF PLASMA-DESKTOP IS INSTALLED

sometime plasma-desktop is not installed so …

run this command kde4 first command kde5 if you have the latest:

type plasma-desktop #kde4
type plasmashell #kde5

if both are empty then you have not plasma installed 😀 , so … if you have not plasma-desktop or shell installed well install it 🙂

(sudo apt-get install plasma-desktop # or similar )

try to login from the console and try to start kde with thi command:

startkde

if nothing happen and you get stuck just do again CTRL ALT F4 or just use again the terminal

CHECK IF YOUR KDE CONFIGURATION HAS SOMETHING OF STRANGE

this code will start kwin without 3d effects … and start system settigns … so you can disable desktop effects … this is not a good stuff i mean it should work and it could be a problem with your video drivers …or it could be just a wrong configuration that you have tried not compatible with your drivers .

KDE4 VERSION

DISPLAY=:0 && KWIN_COMPOSE=N kwin --replace& systemsettings & echo

KDE5 VERSION

DISPLAY=:0 && KWIN_COMPOSE=N kwin_x11 --replace& systemsettings & echo

another test that you could try it’s to rename or maybe mv the kde configs folder

Maybe you don’t remember but you could have done something to kde configs so try to rename your ~/.kde , in some distro ~/.kde4 , in new kde5 you have ~/.config and~/.local   and now try again

KDE5 VERSION

mv ~/.config ~/.configOLD
mv ~/.local ~/.localOLD

KDE4 VERSION

mv ~/.kde ~/.kdeOLD

or

mv ~/.kde4 ~/.kdeOLD

again

try to login from the console and try to start kde with:

startkde

if even with a new configs it doesn’t start … you have system bad configs or bad driver … if says

$DISPLAY is not set or cannot connect to the X server

try to set DISPLAY:0.0 in this way :

export DISPLAY=:0.0 ; startx

if it fails

CHECK XINITRC FILE

in my case i had a bad xinitrc so i have edited this file :

sudo nano /etc/X11/xinit/xinitrc

added this line

exec startkde

pressed CRTL X and saved …

to the terminal :

startx

If it fails :

CHECK IF X CAN STARTS ITSELF PROPERLY WITHOUT KDE

make sure you have twm installed xterm and xclock

if kde doesn’t start try to see if at least X can run with another stuff , disable exec startkde putting # before put this shit on xinitrc

# exec startkde
# start some nice programs

twm &
xclock -geometry 50x50-1+1 &
xterm -geometry 80x50+494+51 &
xterm -geometry 80x20+494-0 &
exec xterm -geometry 80x66+0+0 -name login

you should see something like this , it’s not the same but it looks like this

xclock

if you can see xterm and xclock just type exit and press enter to exit. X is installed properly and the video driver should work fine.

CHECK IF YOU HAVE INSTALLED PROPERLY YOUR VIDEO DRIVER

here i can’t help you because it depends on your video card . To get your video card you can try this

lspci | grep -i vga

i got an ati so i need to :

ATI

sudo apt-get install --reinstall xserver-xorg-video-ati xserver-xorg-core xserver-xorg

if you have another video card you need to replace xserver-xorg-video-ati with one of these :

xserver-xorg-video-nouveau

xserver-xorg-video-intel

xserver-xorg-video-sis

SPACE LEFT SITUATION

as i said before you could have some problem of space , yeah! if you have not enough space in your haddrive kde could even not start … so …

to check this funny stuff you need to use this command line i have excluded HOME because normally it’s the biggest folder in my partition table but anyway if you have 1 partition only you can just remove that option from this command line

cd /; du --block-size=M --max-depth=1 --exclude=home --exclude=archivio --exclude=proc 2>/dev/null | sort -n

it will print a list like this :

2M ./.kde

3M ./oldkde

4M ./Lightworks

5M ./logs

111M ./.mozilla

111M ./.thumbnails

146M ./.q3a

390M ./.config

556M ./.local

1034M ./bin

1389M ./.cache

1404M ./VirtualBox VMs

5159M .

check the biggest folder and remove your stuff tipically you can remove safely /var/tmp/stuff or maybe you can just try to it to another harddrive just to be sure to not lose datas… but they should be only temp-files i had this issue one time for example for a bug in kde …

hope it will help you to start kde again 🙂

trick

start kwin without compisition KDE 4 COMMAND

KWIN_COMPOSE=N kwin --replace

start kwin without compisition KDE 5 COMMAND

KWIN_COMPOSE=N kwin_x11 --replace