package nginx-full 1.6.2-5ubuntu3 failed to install/upgrade: subprocess installed post-installation script returned error exit status 1

Bug #1447294 reported by Lucas Benninger
148
This bug affects 35 people
Affects Status Importance Assigned to Milestone
nginx (Ubuntu)
Invalid
High
Unassigned
Vivid
Invalid
High
Unassigned

Bug Description

Terminal Output:
Setting up nginx-full (1.6.2-5ubuntu3) ...
Job for nginx.service failed. See "systemctl status nginx.service" and "journalctl -xe" for details.
invoke-rc.d: initscript nginx, action "start" failed.
dpkg: error processing package nginx-full (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 nginx-full
E: Sub-process /usr/bin/dpkg returned an error code (1)

Ubuntu Release:
Description: Ubuntu 15.04
Release: 15.04
Program Details
nginx:
  Installed: (none)
  Candidate: 1.6.2-5ubuntu3
  Version table:
     1.6.2-5ubuntu3 0
        500 http://ca.archive.ubuntu.com/ubuntu/ vivid/main amd64 Packages

ProblemType: Package
DistroRelease: Ubuntu 15.04
Package: nginx-full 1.6.2-5ubuntu3
ProcVersionSignature: Ubuntu 3.19.0-15.15-generic 3.19.3
Uname: Linux 3.19.0-15-generic x86_64
ApportVersion: 2.17.2-0ubuntu1
AptOrdering:
 nginx-common: Install
 nginx-full: Install
 nginx-common: Configure
 nginx-full: Configure
 NULL: ConfigurePending
Architecture: amd64
Date: Wed Apr 22 14:24:32 2015
DuplicateSignature: package:nginx-full:1.6.2-5ubuntu3:subprocess installed post-installation script returned error exit status 1
ErrorMessage: subprocess installed post-installation script returned error exit status 1
InstallationDate: Installed on 2014-08-13 (251 days ago)
InstallationMedia: Ubuntu 14.04 LTS "Trusty Tahr" - Release amd64 (20140417)
RelatedPackageVersions:
 dpkg 1.17.25ubuntu1
 apt 1.0.9.7ubuntu4
SourcePackage: nginx
Title: package nginx-full 1.6.2-5ubuntu3 failed to install/upgrade: subprocess installed post-installation script returned error exit status 1
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Lucas Benninger (lucas8060-deactivatedaccount) wrote :
tags: removed: need-duplicate-check
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in nginx (Ubuntu):
status: New → Confirmed
Changed in nginx (Ubuntu):
importance: Undecided → High
Revision history for this message
Thomas Ward (teward) wrote :

I've been able to run the install command from the DpkgHistoryLog (specifically for nginx) without any incident. It installs from the repositories correctly and operates as expected.

So, this will need a little more information. Since dpkg's logs don't actually give any information or insight into why the executable failed to load, lets do some digging.

Run this command: `systemctl status nginx.service` and likely this command: `journalctl -xe` and provide the output. My guess is that something broke during its startup (something else bound to port 80 or such), but because of the way the init scripts have been changed over time and the systemd issue of it failing to report those errors, we'll need to do some investigation to try and find *why* it's breaking.

Also, try `sudo nginx` and then see what errors, if any, are produced.

Thomas Ward (teward)
Changed in nginx (Ubuntu Vivid):
status: Confirmed → Incomplete
Revision history for this message
Francis De Brabandere (francisdb) wrote :

systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2015-05-07 10:47:47 EDT; 8min ago
  Process: 540 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)

then I tried
sudo /usr/sbin/nginx -t -q -g "daemon on; master_process on;"

and
sudo tail -n 100 /var/log/nginx/error.log

which revealed
2015/05/07 10:47:47 [emerg] 540#0: host not found in upstream "localhost:8080" in /etc/nginx/sites-enabled/foo.bar.com:2

but strangely this one seems to work
sudo service nginx start

any clues?

Revision history for this message
Francis De Brabandere (francisdb) wrote :

temporary fix:

instead of

upstream jenkins {
  server localhost:8080 fail_timeout=0;
}

we now use

upstream jenkins {
  server 127.0.0.1:8080 fail_timeout=0;
}

Revision history for this message
Thomas Ward (teward) wrote :

Francis,

This is a known issue. In the nginx community, we actually list the use of any type of hostname, including localhost, a pitfall, as nginx might not be able to resolve the hostname at a service restart or at boot time. Below is the content of this documentation (which I had a hand in writing) that details why using hostnames in upstream or listen statements is bad: (http://docs.ngx.cc/en/latest/topics/tutorials/config_pitfalls.html#using-a-hostname-to-resolve-addresses)

Using a Hostname to Resolve Addresses

BAD:

upstream {
    server http://someserver;
}

server {
    listen myhostname:80;
    # [...]
}

You should never use a hostname in a listen directive. While this may work, it will come with a large number of issues. One such issue being that the hostname may not resolve at boot time or during a service restart. This can cause Nginx to be unable to bind to the desired TCP socket which will prevent Nginx from starting at all.

A safer practice is to know the IP address that needs to be bound to and use that address instead of the hostname. This prevents Nginx from needing to look up the address and removes dependencies on external and internal resolvers.

This same issue applies to upstream locations. While it may not always be possible to avoid using a hostname in an upstream block, it is bad practice and will require careful considerations to prevent issues.

GOOD:

upstream {
    server http://10.48.41.12;
}

server {
    listen 127.0.0.16:80;
    # [...]
}

Revision history for this message
Thomas Ward (teward) wrote :

In addition to this being a known issue, there is also currently no known way to resolve this issue.

summary: - package nginx-full 1.6.2-5ubuntu3 failed to install/upgrade: subprocess
- installed post-installation script returned error exit status 1
+ package nginx-full 1.6.2-5ubuntu3 failed to install/upgrade due to
+ configuration file using a 'hostname' to try and resolve an IP address
+ (for upstream block)
Revision history for this message
Francis De Brabandere (francisdb) wrote : Re: package nginx-full 1.6.2-5ubuntu3 failed to install/upgrade due to configuration file using a 'hostname' to try and resolve an IP address (for upstream block)

Ok, strange that this problem suddenly appeared in 15.04 vivid

I might have hijacked this bug report as the original issue might be unrelated?

Revision history for this message
Francis De Brabandere (francisdb) wrote :

By the way, the nginx upstream module docs use names instead of ip addresses...

http://nginx.org/en/docs/http/ngx_http_upstream_module.html

Revision history for this message
Thomas Ward (teward) wrote :

What the docs use and what are actually used are different.

Francis: Also in the future, file a bug with your own information, I believe. Since i have no information from the OP of *this* bug, and you've posted something that might not be related, I have to treat everything as separate. Note that your issue which you've posted here (maybe a hijack) is a "Won't Fix" situation because it's a "Can't Fix" problem.

summary: - package nginx-full 1.6.2-5ubuntu3 failed to install/upgrade due to
- configuration file using a 'hostname' to try and resolve an IP address
- (for upstream block)
+ package nginx-full 1.6.2-5ubuntu3 failed to install/upgrade: subprocess
+ installed post-installation script returned error exit status 1
Revision history for this message
Thomas Ward (teward) wrote :

This bug will remain at "Incomplete" until the original bug poster, Lucas Benninger, provides requested information.

Revision history for this message
Donald Sitze (donald-sitze) wrote :

For what it's worth, I had this problem and found that because the default Ubuntu installation apparently includes Apache2 httpd server, which was active on port 80, the nginx core installer failed when it tried to start the nginx service. This port conflict and subsequent failure of the nginx service caused the error in the installer.

I disabled the apache server and nginx installation then completed without errors.

Revision history for this message
Xkeeper (xkeeper) wrote :

I encountered the error donalld-sitze did and the same solution solved my problem (removing apache2). However, the "system problem" dialog directed me to bug #1449903 instead of this one (when commenting on that one warns me it is a duplicate of this one...)

Revision history for this message
Wenceslaus Dsilva (deadmantfa) wrote :

I am getting the same error, I do not have apache installed still getting this error, also as mentioned above i cant find conf file to make the changes as described

Revision history for this message
Thomas Ward (teward) wrote :

Xkeeper:
deadmantfa:
Donald:

There's no evidence YOUR issues are actually the same as the OP of *this* bug. You need to make your own bugs with your own set of information. Currently, the state of the package is such that there is no useful debug data. If you are getting the same "Job for nginx.service failed." issues during installation or upgrade of the package, you need to check `journalctl -xe --unit=nginx.service` and `systemctl status -l nginx.service` to see what errors are being produced.

There is a pending bug https://bugs.launchpad.net/ubuntu/+source/nginx/+bug/1472683 which will address the failure to include reliable debug information on nginx package-problem bugs going forward for Vivid and Wily, however it is not yet ready for inclusion nor does it help the currently existing bugs.

Revision history for this message
Thomas Ward (teward) wrote :

Thank you for filing this bug.

We have replaced the 1.6.2-5ubuntu3 package with 1.6.2-5ubuntu3.1, which contains configuration in order to make additional debug data available in the bug.

Given that, and given that it is impossible to determine from this bug what is actually breaking as the Original Poster of this bug has not attached any additional information, I am marking this bug as "Invalid", and strongly recommend that if you have this issue with the 1.6.2-5ubuntu3.1 package that's available in Vivid now you should file a bug against that instead.

Changed in nginx (Ubuntu Vivid):
status: Incomplete → Invalid
Changed in nginx (Ubuntu):
status: Incomplete → Invalid
Revision history for this message
Thomas Ward (teward) wrote :

Note we also have an updated package in Wily, as well, so if this issue is replicated in Wily, we will get usable debug data.

Revision history for this message
Maciej Lutostański (lutostanski-maciej) wrote :

Setting up nginx-core (1.6.2-5ubuntu3.1) ...
Job for nginx.service failed. See "systemctl status nginx.service" and "journalctl -xe" for details.
invoke-rc.d: initscript nginx, action "start" failed.
dpkg: error processing package nginx-core (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of nginx:
 nginx depends on nginx-core (>= 1.6.2-5ubuntu3.1) | nginx-full (>= 1.6.2-5ubuntu3.1) | nginx-light (>= 1.6.2-5ubuntu3.1) | nginx-extras (>= 1.6.2-5ubuntu3.1); however:
  Package nginx-core is not configured yet.
  Package nginx-full is not installed.
  Package nginx-light is not installed.
  Package nginx-extras is not installed.
 nginx depends on nginx-core (<< 1.6.2-5ubuntu3.1.1~) | nginx-full (<< 1.6.2-5ubuntu3.1.1~) | nginx-light (<< 1.6.2-5ubuntu3.1.1~) | nginx-extras (<< 1.6.2-5ubuntu3.1.1~); however:
  Package nginx-core is not configured yet.
  Package nginx-full is not installed.
  Package nginx-light is not installed.
  Package nginx-extras is not installed.

dpkg: error processing package nginx (--configure):
 dependency problems - leaving uNo apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                                                          nconfigured
Errors were encountered while processing:
 nginx-core
 nginx
E: Sub-process /usr/bin/dpkg returned an error code (1)

Revision history for this message
Thomas Ward (teward) wrote :

@Maciej Lutostanski:

This bug here is marked Invalid as it is not giving us information, and is against a superseded version of the package.

Please file a new bug with your information. You may wish to navigate to /var/crash/, look for a .crash item related to nginx, then run `ubuntu-bug /var/crash/THE_CRASH_FILE_NAME_HERE` in order to generate a new bug, which will also collect important debug information we need to diagnose these issues.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.