E: Unable to correct problems, you have held broken packages

Currently I am trying to install the onlyoffice documentserver, so that I can run onlyoffice in my nextcloud but as soon as I run

sudo apt-get install onlyoffice-documentserver

the following error message occurs:

The following packages have unmet dependencies:
 onlyoffice-documentserver : Depends: nodejs (>= 6.9.1) but 0.10.25~dfsg2-2ubuntu1 is to be installed
E: Unable to correct problems, you have held broken packages.

After that I installed nodejs according to this manual: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions but the error message only changed to:

The following packages have unmet dependencies:
 onlyoffice-documentserver : Depends: nodejs (< 7.0.0) but 8.11.1-1nodesource1 is to be installed
E: Unable to correct problems, you have held broken packages.

I have searched popular Linux forums and google and tried different things like

sudo apt-get autoclean
sudo apt-get autoremove
sudo apt-get -f install
dpkg --configure -a
sudo apt-get remove --auto-remove nodejs

but nothing seems to work. Neither trying to fix the error or trying to remove the package. The package will get removed but the error stays the same. I would really appreciate some help because I am out of ideas.

The server is a vserver running Ubuntu 14.04 with Plesk on top (where I can also install nodejs, but the error message also stays the same).

try aptitude -f
see if that works

Only a graphical package manager starts but nothing happens

Try: sudo apt update --fix-missing

1 Like

Disable all non-default repos then clean, update & upgrade to fix your packages.

It’s a dependency issue, the repo you’ve added is incompatible with your system.


Try using dpkg -l search for node js in the list and use the name to remove it.

then remove the Repos
sudo apt-add-repository --remove ( insert ppa here)

Or purge the PPA:
sudo ppa-purge


Then install this way.

get the deb package.
wget http://download.onlyoffice.com/install/desktop/editors/linux/onlyoffice-desktopeditors_amd64.deb

once downloaded install the package with dpkg tool
sudo dpkg -i onlyoffice-desktopeditors_amd64.deb

f there’s any dependency errors, then run the following command:
sudo apt -f install

OnlyOffice will be installed under /opt/ directory. After it’s installed, start the application from your app launcher or from command line.


Since I didn’t know the exact name of the PPA I had to remove the onlyoffice.list and nodesource.list in the sources.list.d folder. This way I managed to get rid of the held packages error but I am still not able to install the onlyoffice documentserver either because as soon as I add the onlyoffice repo I get the error about nodejs again. Since they don’t offer a .deb file to install manually I have to pause this project I guess

Install PostgreSQL from Ubuntu repository
sudo apt install postgresql
Then create the onlyoffice database.

sudo -u postgres psql -c “CREATE DATABASE onlyoffice;”
Create the onlyoffice user.

sudo -u postgres psql -c “CREATE USER onlyoffice WITH password ‘onlyoffice’;”
Grant permission.

sudo -u postgres psql -c “GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;”

Install NodeJS from official repository
OnlyOffice document server requires nodejs 6.9.1+, but the version in Ubuntu repository is outdated, so we will need to install the latest LTS version (6.10.0) of Node.js from upstream repository.

Add Node.js repostiory.

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
Install Node.js.

sudo apt install nodejs
Check Node.js version.

node -v
Sample output:


Install Redis server and Rabbitmq
sudo apt install redis-server rabbitmq-server
Check their status.

systemctl status redis-server

systemctl status rabbitmq-server
You should see they are active (running). If rabbitmq-server failed to start, that’s mostly because of low memory on the machine or invalid hostname.

Install OnlyOffice document server
Add OnlyOffice repository with the following command.

echo “deb http://download.onlyoffice.com/repo/debian squeeze main” | sudo tee /etc/apt/sources.list.d/onlyoffice.list
Import OnlyOffice public key.

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5
Update local package index and install OnlyOffice document server. Note that Nginx will be installed as the web server so you might need to stop Apache if it’s running.

sudo apt update

sudo apt install onlyoffice-documentserver
During the installation process, you will be asked to enter PostgreSQL password for onlyoffice. Enter “onlyoffice” (without double quotes).

You also need to accept the Microsoft license terms in order to install TrueType core fonts from Microsoft.

Once the installation is finished, enter your server’s public IP address in web browser, you should see “Document Server is running”

To connect NextCloud to OnlyOffice document server, the latter must be running in HTTPS mode. The following steps show how to obtain and install Let’s Encrypt TLS certificate.

Edit /etc/nginx/conf.d/onlyoffice-documentserver.conf file.

sudo nano /etc/nginx/conf.d/onlyoffice-documentserver.conf
Change the configuration like below. Don’t forget to set an A record for onlyoffice.your-domain.com.

include /etc/nginx/includes/onlyoffice-http.conf;
server {
listen [::]:80 default_server;
server_name onlyoffice.your-domain.com;
server_tokens off;

include /etc/nginx/includes/onlyoffice-documentserver-*.conf;

location ~ /.well-known/acme-challenge {
root /var/www/onlyoffice/;
allow all;
Save and close the file. Reload Nginx for the changes to take effect.

sudo systemctl reload nginx
Then install certbot (Let’s Encrypt) client.

sudo apt install letsencrypt
Next, run the following command to obtain a free TLS certificate using the webroot plugin.

sudo letsencrypt certonly --webroot --agree-tos --email your-email-address -d onlyoffice.your-domain.com -w /var/www/onlyoffice/
Within a few seconds, you shall see a message like below, which means the TLS certificate is successfully obtained.

Edit onlyoffice-documentserver.conf file.

sudo nano /etc/nginx/conf.d/onlyoffice-documentserver.conf

Delete everything in that file and paste the following text into the file. Change the red text accordingly.

include /etc/nginx/includes/onlyoffice-http.conf;

Normal HTTP host

server {
listen [::]:80 default_server;
server_name onlyoffice.your-domain.com;
server_tokens off;

Redirects all traffic to the HTTPS host

root /nowhere; ## root doesn’t have to be a valid path since we are redirecting
rewrite ^ https://$host$request_uri? permanent;
#HTTP host for internal services
server {
listen [::1]:80;
server_name localhost;
server_tokens off;
include /etc/nginx/includes/onlyoffice-documentserver-common.conf;
include /etc/nginx/includes/onlyoffice-documentserver-docservice.conf;

HTTPS host

server {
listen ssl;
listen [::]:443 ssl default_server;
server_name onlyoffice.your-domain.com;
server_tokens off;
root /usr/share/nginx/html;

ssl_certificate /etc/letsencrypt/live/onlyoffice.your-domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/onlyoffice.your-domain.com/privkey.pem;

modern configuration. tweak to your needs.

ssl_protocols TLSv1.2;
ssl_prefer_server_ciphers on;

HSTS (ngx_http_headers_module is required) (15768000 seconds = 6 months)

add_header Strict-Transport-Security max-age=15768000;

ssl_session_cache builtin:1000 shared:SSL:10m;

add_header X-Frame-Options SAMEORIGIN;

add_header X-Content-Type-Options nosniff;

ssl_stapling on;

ssl_stapling_verify on;

ssl_trusted_certificate /etc/nginx/ssl/stapling.trusted.crt;

resolver valid=300s; # Can change to your DNS resolver if desired

resolver_timeout 10s;

[Optional] Generate a stronger DHE parameter:

cd /etc/ssl/certs

sudo openssl dhparam -out dhparam.pem 4096

#ssl_dhparam {{SSL_DHPARAM_PATH}};

location ~ /.well-known/acme-challenge {
root /var/www/onlyoffice/;
allow all;
include /etc/nginx/includes/onlyoffice-documentserver-*.conf;

Save and close the file. Then test Nginx configuration and reload.

sudo nginx -t

sudo systemctl reload nginx
Visit https://onlyoffice.your-domain.com in web browser to verify OnlyOffice document server is running correctly in HTTPS mode.

Installing Nextcloud OnlyOffice Integration App
SSH into your Nextloud server, and then change directory to the Nextcloud apps directory.

cd /var/www/nextcloud/apps/
Next, download Nextcloud OnlyOffice integration app using the following command.

sudo git clone https://github.com/ONLYOFFICE/onlyoffice-owncloud.git onlyoffice
Then go to Nextcloud Apps page, click Not Enabled tab and enable the OnlyOffice app.

After that, go to Nextcloud admin page, select Additional Settings tab on the left pane and enter the domain name for OnlyOffice in Document Editing Service Address field.

After saving the above setting, you should be able to create documents, spreedsheets and presentation files within Nextcloud by clicking the plus (+) button. A separate tab will be opened for editing.
You will also see a new item called “Open in OnlyOffice” in the context menu of office documents.

Installing OnlyOffice Document Server and Nextcloud on the Same Machine
The OnlyOffice Document server uses Nginx as web server.

If you have an existing Nextcloud server running with Nginx, then there’s no damage to your Nextcloud server when installing OnlyOffice on the same machine. It will remove nginx-core and install nginx-extras package, so there’ll be a little downtime, but your configurations will be intact.

If you have an existing Nextcloud server running with Apache web server, and you want to install OnlyOffice on the same machine, then you have two choices:

Stop/remove Apache, install Nginx as the web server for both Nextcloud and OnlyOffice. You can use the Nextcloud Nginx config in this tutorial.
Configure Nginx as a reverse proxy for Apache.
Configuring Nginx as a Reverse Proxy for Apache
If you choose the second route, then you should first change the port number of Apache before you install OnlyOffice document server.

Edit the ports.conf file.

sudo nano /etc/apache2/ports.conf
Find the line:

Listen 80
Change it to a different port number like 8180. Note that you shouldn’t use 8080 here because OnlyOffice document server needs port 8080 to start its docservice.

Listen 8180
You should also change the SSL port number because later Nginx will do the SSL termination. Find the line:

Listen 443
Change the port number to something like 4433.

Listen 4433
Save and close the file. Next, edit the virtual host file for Nextcloud.

sudo nano /etc/apache2/sites-enabled/nextcloud.conf
The first line should be like this:

<VirtualHost *:80>
Change the port number to 8180.

<VirtualHost *:8180>
We should also disable redirecting HTTP to HTTPS by adding comment characters before the following lines. (Your Nextcloud server is using HTTPS connection, right?)

#RewriteEngine on
#RewriteCond %{SERVER_NAME} =nextcloud.your-domain.com
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
And change the SSL listening port.

<VirtualHost *:443>
Change the above port to 4433. Save and close the file. Reload Apache configuration.

sudo systemctl reload apache2
Now Apache listens on port 8180 and 4433. We can then follow the above instructions to install OnlyOffice document server, which will install Nginx in the process.

Once OnlyOffice document server and Nginx are installed, create an Nginx server block file to proxy requests to Apache.

sudo nano /etc/nginx/conf.d/nextcloud-proxy.conf
Add the following lines to the file. Replace the domain name with your own. The path for ssl_certificate and ssl_certificate_key is for Let’s Encrypt issued certificates. If you use a certificate issued by another CA, then you should enter your own path.

server {
listen 80;
server_name nextcloud.your-domain.com;
return 301 https://$server_name$request_uri;

server {
listen 443 ssl http2;
server_name nextcloud.your-domain.com;

    ssl_certificate /etc/letsencrypt/live/nextcloud.your-domain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/nextcloud.your-domain.com/privkey.pem;

    ssl_session_timeout 1d;
    ssl_session_cache shared:SSL:10m;
    ssl_session_tickets off;
    ssl_protocols TLSv1.1 TLSv1.2;

    add_header Strict-Transport-Security max-age=15768000;

    ssl_prefer_server_ciphers on;

    location / {
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

The location / {…} section redirects all requests to Apache web server listening on port 8180. Save and close the file. Then test Nginx configuration.

sudo nginx -t
Reload Nginx if syntax is OK.

sudo systemctl reload nginx
Now you should be able to visit your Nextcloud server as usual, without adding a port number in the URL. If you use the following cURL command to fetch HTTP header, then you should see the front-end server is Nginx.

curl -I https://nextcloud.your-domain.com
Sample output:

HTTP/1.1 302 Found
Server: nginx/1.11.9
Date: Tue, 14 Mar 2017 08:55:30 GMT
Content-Type: text/html; charset=UTF-8
That’s it!

Maybe this will work for you.:grinning:

1 Like

Wow, thank you! I have to try this on the weekend when I have plenty of time.

No worries, let me know how it goes.