Fixing vncserver startup failure due to pam_nologin.

Recently, after upgrading my main system to Fedora 27, I found my vncservers were intermittently failing to start on boot.

Status messages indicated the pam_nologin module was involved, and servers were failing to start because /var/run/nologin had not been removed yet.

For anyone else who hits this issue, all it means is things are starting up faster on F27, and systemd is trying to start your vncservers before the system is ready for user logins (derp).

The fix is easy, just add systemd-user-sessions.service to the “After” line in the systemd vncserver template file, and in any vncserver units you’ve already created from your template file.

So your template file should look something like this:

Description=Remote desktop service (VNC) systemd-user-sessions.service


# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver %i -geometry 1300x700 -alwaysshared -fg -xstartup /home/jss/.vnc/xstartup


#-fg is necessary so vncserver stays in foreground, otherwise, the systemd user session shuts down as
#soon as vncserver forks off its daemon process and the parent exits.

Leave a Reply

Your email address will not be published. Required fields are marked *