NoMachine Support

Your questions answered

Knowledge Base

Searching in: Articles & FAQs
Filter the search results
Applies to:
Last update:
Searching in: Articles & FAQs
ID: AR08N00898
Applies to: NX Software
Added on: 2016-08-11
Last update: 2018-12-04
How to solve 'session negotiation failed, application terminated prematurely'

If the user gets this message when connecting to a Linux host:

"The session negotiation failed.  Error: Session failed, application terminated prematurely."

it means that the application run by NoMachine node (i.e. the desktop environment or a custom application) terminated immediately after being started.

This can happen when the command specified for launching the desktop or the custom application is not appropriate.

The command to start the Linux desktop environment is defined in the DefaultDesktopCommand key in the node configuration file (/usr/NX/etc/node.cfg).

For example:
DefaultDesktopCommand "/etc/X11/Xsession 'gnome-session --session=ubuntu'"

In order to check if the command is correct, you can do the following:

1) Find out which is the desktop environments installed on your system by executing this command in a terminal:

     ls /usr/share/xsessions

2) Then retrieve the command to start the desktop of your choice. Such command is written in the *.desktop file in the line starting with Exec.

For example:
grep ^Exec /usr/share/xsessions/gnome.desktop
returns:
Exec=gnome-session

For further examples, please refer also to this article: https://www.nomachine.com/AR04K00667#2.1


3) Once you've retrieved the command, ensure it's set in the DefaultDesktopCommand key in node.cfg. In this example it should be:
DefaultDesktopCommand gnome-session

Restarting the server is not necessary, this change will become effective when the new session is started.


For custom sessions, the application run by the node is specified in the client User Interface, e.g. 'Run the console' or the program set in 'Run the following command'.

When the application terminates immediately, the following error is reported in the connection log file:

NX> 501 Session failed, application terminated prematurely.
NX> 598 Error: failed to connect to nxclient --monitor.

and in the session log file on the end-user's host:

3579 3579 15:18:18 658.862 ClientSession: Failing reason is 'The session negotiation failed. Error: Session failed, application terminated prematurely.'

These files are stored in the NoMachine session directory created in the user's home/.nx directory.

When error 'application terminated prematurely' is present, it may be helpful to look for a possible cause of the problem in these files on the remote host:

1) The clients file in the  /usr/NX/var/log/node/C-<session> directory. 

For example:  /usr/NX/var/log/node/C-testdrive2-1005-246612EE435B150D4A8D37463B948139/clients

The NoMachine node redirects the standard error of X applications to this file.

When running a virtual desktop, however, it should be considered that the X display manager usually redirects the standard error to: ~/.xsession-errors and the NoMachine clients file can be empty.

2) The .xsession-errors file in the user's home.

For example:  /home/nxtest01/.xsession-errors

3) The system log.

For example: /var/log/messages on Ubuntu

Additionally, the following test could also provide useful information:

- Launch a NoMachine custom session and select:  'Run the console' + 'Run the command in a virtual desktop'

- Inside this console, execute the same command set in the DefaultDesktopCommand key in the node configuration key.