Nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)

Hello there, same thing happened to me.

Sorry in advance I am a newbie with nginx.

I was following instructions [https://certbot.eff.org/#ubuntuxenial-nginx] to install a certificate in nginx, and the command sudo certbot renew --dry-run output the exact same thing.

Could it be that certbot renew has changed the configuration file in /etc/nginx/sites-available/default ?

nginx version: nginx/1.10.3 (Ubuntu)

By the way: I chose the option 2: redirect any http request to https.

This is the error I’m getting. I can confirm before installing certbot nginx was working fine (out-of-the-box).

$ sudo systemctl status nginx

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 Mon 2018-02-12 20:52:53 CET; 7min ago
Process: 4805 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Process: 4800 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 1904 (code=exited, status=0/SUCCESS)

nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
systemd[1]: nginx.service: Control process exited, code=exited status=1
systemd[1]: Failed to start A high performance web server and a reverse proxy server.
systemd[1]: nginx.service: Unit entered failed state.
systemd[1]: nginx.service: Failed with result ‘exit-code’.

Ok, now this is weird. I am pretty sure nginx service was stopped. And I don’t have apache or anything running on the server that could use port 80… Could it have been that nginx left some resource that kept port 80 busy while certbot reconfigured/restarted the server?

I killed everything running on port 80…

$ sudo fuser -k 80/tcp
80/tcp: 3488 3489 3490

after that nginx started normally…

Hi @rgrz,

I split your question into a different topic because even though you get a similar error it is probably caused by something else, since you are using --nginx mode and not --standalone mode.

I suspect in your case you just have a different service enabled that is also taking up port 80. Since you already killed it, it’s impossible to tell what it was. If it happens again, you could run fuser without the -k option to identify the process ID numbers without killing them and then run pgrep with those process ID numbers to identify what program is holding the port.

In the meantime, if you share the output of systemctl list-unit-files it might reveal a conflicting service.

3 Likes

BTW, my favorite incantation for this is:

fuser -kivn tcp 80

-i makes it prompt before killing, and -v prints the process name in addition to the process id.

4 Likes

Thanks for your quick replay, here’s the output of $ systemctl list-unit-files

UNIT FILE STATE
proc-sys-fs-binfmt_misc.automount static
dev-hugepages.mount static
dev-mqueue.mount static
proc-sys-fs-binfmt_misc.mount static
sys-fs-fuse-connections.mount static
sys-kernel-config.mount static
sys-kernel-debug.mount static
acpid.path enabled
systemd-ask-password-console.path static
systemd-ask-password-plymouth.path static
systemd-ask-password-wall.path static
systemd-networkd-resolvconf-update.path static
accounts-daemon.service enabled
acpid.service disabled
apport-forward@.service static
apt-daily-upgrade.service static
apt-daily.service static
atd.service enabled
autovt@.service enabled
bootlogd.service masked
bootlogs.service masked
bootmisc.service masked
certbot.service static
checkfs.service masked
checkroot-bootclean.service masked
checkroot.service masked
cloud-config.service enabled
cloud-final.service enabled
cloud-init-local.service enabled
cloud-init.service enabled
console-getty.service disabled
console-setup.service static
console-shell.service disabled
container-getty@.service static
cron.service enabled
cryptdisks-early.service masked
cryptdisks.service masked
dbus-org.freedesktop.hostname1.service static
dbus-org.freedesktop.locale1.service static
dbus-org.freedesktop.login1.service static
dbus-org.freedesktop.network1.service disabled
dbus-org.freedesktop.resolve1.service disabled
dbus-org.freedesktop.timedate1.service static
dbus.service static
debug-shell.service disabled
dm-event.service disabled
emergency.service static
friendly-recovery.service enabled
fuse.service masked
getty-static.service static
getty@.service enabled
halt.service masked
hostname.service masked
hwclock.service masked
ifup@.service static
initrd-cleanup.service static
initrd-parse-etc.service static
initrd-switch-root.service static
initrd-udevadm-cleanup-db.service static
iscsi.service enabled
iscsid.service enabled
keyboard-setup.service disabled
killprocs.service masked
kmod-static-nodes.service static
kmod.service static
lvm2-lvmetad.service disabled
lvm2-lvmpolld.service disabled
lvm2-monitor.service enabled
lvm2-pvscan@.service static
lvm2.service masked
lxcfs.service enabled
lxd-bridge.service static
lxd-containers.service enabled
lxd.service indirect
mdadm-shutdown.service disabled
module-init-tools.service static
motd.service masked
mountall-bootclean.service masked
mountall.service masked
mountdevsubfs.service masked
mountkernfs.service masked
mountnfs-bootclean.service masked
mountnfs.service masked
networking.service enabled
nginx.service enabled
open-iscsi.service enabled
open-vm-tools.service enabled
plymouth-halt.service static
plymouth-kexec.service static
plymouth-log.service static
plymouth-poweroff.service static
plymouth-quit-wait.service static
plymouth-quit.service static
plymouth-read-write.service static
plymouth-reboot.service static
plymouth-start.service static
plymouth-switch-root.service static
plymouth.service static
polkitd.service static
pollinate.service enabled
procps.service static
quotaon.service static
rc-local.service static
rc.local.service static
rc.service masked
rcS.service masked
reboot.service masked
rescue.service static
resolvconf.service enabled
rippled.service enabled
rmnologin.service masked
rsync.service disabled
rsyslog.service enabled
screen-cleanup.service masked
sendsigs.service masked
serial-getty@.service disabled
setvtrgb.service static
sigpwr-container-shutdown.service static
single.service masked
snapd.autoimport.service enabled
snapd.core-fixup.service enabled
snapd.refresh.service static
snapd.service enabled
snapd.snap-repair.service static
snapd.system-shutdown.service enabled
ssh.service enabled
ssh@.service static
sshd.service enabled
stop-bootlogd-single.service masked
stop-bootlogd.service masked
syslog.service enabled
systemd-ask-password-console.service static
systemd-ask-password-plymouth.service static
systemd-ask-password-wall.service static
systemd-backlight@.service static
systemd-binfmt.service static
systemd-bootchart.service disabled
systemd-bus-proxyd.service static
systemd-exit.service static
systemd-fsck-root.service static
systemd-fsck@.service static
systemd-fsckd.service static
systemd-halt.service static
systemd-hibernate-resume@.service static
systemd-hibernate.service static
systemd-hostnamed.service static
systemd-hwdb-update.service static
systemd-hybrid-sleep.service static
systemd-initctl.service static
systemd-journal-flush.service static
systemd-journald.service static
systemd-kexec.service static
systemd-localed.service static
systemd-logind.service static
systemd-machine-id-commit.service static
systemd-modules-load.service static
systemd-networkd-resolvconf-update.service static
systemd-networkd-wait-online.service disabled
systemd-networkd.service disabled
systemd-poweroff.service static
systemd-quotacheck.service static
systemd-random-seed.service static
systemd-reboot.service static
systemd-remount-fs.service static
systemd-resolved.service disabled
systemd-rfkill.service static
systemd-suspend.service static
systemd-sysctl.service static
systemd-timedated.service static
systemd-timesyncd.service enabled
systemd-tmpfiles-clean.service static
systemd-tmpfiles-setup-dev.service static
systemd-tmpfiles-setup.service static
systemd-udev-settle.service static
systemd-udev-trigger.service static
systemd-udevd.service static
systemd-update-utmp-runlevel.service static
systemd-update-utmp.service static
systemd-user-sessions.service static
udev.service static
ufw.service enabled
umountfs.service masked
umountnfs.service masked
umountroot.service masked
unattended-upgrades.service enabled
urandom.service static
ureadahead-stop.service static
ureadahead.service enabled
user@.service static
uuidd.service indirect
x11-common.service masked
-.slice static
machine.slice static
system.slice static
user.slice static
acpid.socket enabled
apport-forward.socket enabled
dbus.socket static
dm-event.socket enabled
lvm2-lvmetad.socket enabled
lvm2-lvmpolld.socket enabled
lxd.socket enabled
snapd.socket enabled
ssh.socket disabled
syslog.socket static
systemd-bus-proxyd.socket static
systemd-fsckd.socket static
systemd-initctl.socket static
systemd-journald-audit.socket static
systemd-journald-dev-log.socket static
systemd-journald.socket static
systemd-networkd.socket disabled
systemd-rfkill.socket static
systemd-udevd-control.socket static
systemd-udevd-kernel.socket static
uuidd.socket enabled
basic.target static
bluetooth.target static
busnames.target static
cloud-config.target static
cloud-init.target static
cryptsetup-pre.target static
cryptsetup.target static
ctrl-alt-del.target disabled
default.target static
emergency.target static
exit.target disabled
final.target static
getty.target static
graphical.target static
halt.target disabled
hibernate.target static
hybrid-sleep.target static
initrd-fs.target static
initrd-root-fs.target static
initrd-switch-root.target static
initrd.target static
kexec.target disabled
local-fs-pre.target static
local-fs.target static
mail-transport-agent.target static
multi-user.target static
network-online.target static
network-pre.target static
network.target static
nss-lookup.target static
nss-user-lookup.target static
paths.target static
poweroff.target disabled
printer.target static
reboot.target disabled
remote-fs-pre.target static
remote-fs.target enabled
rescue.target disabled
rpcbind.target static
runlevel0.target disabled
runlevel1.target disabled
runlevel2.target static
runlevel3.target static
runlevel4.target static
runlevel5.target static
runlevel6.target disabled
shutdown.target static
sigpwr.target static
sleep.target static
slices.target static
smartcard.target static
sockets.target static
sound.target static
suspend.target static
swap.target static
sysinit.target static
system-update.target static
time-sync.target static
timers.target static
umount.target static
apt-daily-upgrade.timer enabled
apt-daily.timer enabled
certbot.timer enabled
snapd.refresh.timer enabled
snapd.snap-repair.timer enabled
systemd-tmpfiles-clean.timer static
ureadahead-stop.timer static

283 unit files listed.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.