I decided to follow the Multiple Blogs Tutorial to set up a second ghost instance on a droplet. Already had a second nginx config file set up to run a second domain and was testing that site. Shut down both ghost and nginx with ‘service ghost stop’ and ‘service nginx stop’. No error messages seen.
Modified the second nginx config file in sites-enabled and attempted to restart nginx with ‘service nginx restart’. Saw ‘Job for nginx.service failed because the control process exited with error code. See “systemctl status nginx.service” and “journalctl -xe” for details.’
The error log shows:
2017/09/15 04:09:48 [emerg] 24518#24518: bind() to 0.0.0.0:80 failed (98: Address already in use)
2017/09/15 04:09:48 [emerg] 24518#24518: bind() to [::]:80 failed (98: Address already in use)
2017/09/15 04:09:48 [emerg] 24518#24518: bind() to 0.0.0.0:443 failed (98: Address already in use)
2017/09/15 04:09:48 [emerg] 24518#24518: bind() to 0.0.0.0:80 failed (98: Address already in use)
2017/09/15 04:09:48 [emerg] 24518#24518: bind() to [::]:80 failed (98: Address already in use)
2017/09/15 04:09:48 [emerg] 24518#24518: bind() to 0.0.0.0:443 failed (98: Address already in use)
2017/09/15 04:09:48 [emerg] 24518#24518: bind() to 0.0.0.0:80 failed (98: Address already in use)
2017/09/15 04:09:48 [emerg] 24518#24518: bind() to [::]:80 failed (98: Address already in use)
2017/09/15 04:09:48 [emerg] 24518#24518: bind() to 0.0.0.0:443 failed (98: Address already in use)
2017/09/15 04:09:48 [emerg] 24518#24518: bind() to 0.0.0.0:80 failed (98: Address already in use)
2017/09/15 04:09:48 [emerg] 24518#24518: bind() to [::]:80 failed (98: Address already in use)
2017/09/15 04:09:48 [emerg] 24518#24518: bind() to 0.0.0.0:443 failed (98: Address already in use)
2017/09/15 04:09:48 [emerg] 24518#24518: bind() to 0.0.0.0:80 failed (98: Address already in use)
2017/09/15 04:09:48 [emerg] 24518#24518: bind() to [::]:80 failed (98: Address already in use)
2017/09/15 04:09:48 [emerg] 24518#24518: bind() to 0.0.0.0:443 failed (98: Address already in use)
2017/09/15 04:09:48 [emerg] 24518#24518: still could not bind()
Attempted to revert back to previous config file. Still fails. Ran ‘nginx -t’ and saw no syntax errors. Ran ‘ps -aux’ and see:
root@ghost-1gb-sfo2-01:/etc/nginx/sites-enabled# ps -aux | grep nginx
root 24899 0.0 0.0 12948 940 pts/0 S+ 04:34 0:00 grep --color=auto nginx
root 31045 0.0 0.3 126944 3452 ? Ss Sep02 0:00 nginx: master process nginx -c /etc/nginx/nginx.conf
www-data 31053 0.0 0.5 127096 6072 ? S Sep02 0:11 nginx: worker process
What’s going on here? Shouldn’t the ‘service nginx stop’ have killed all the processes? Is that what is causing the restart to fail?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
# netstat -ltnp | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 31045/nginx.conf
tcp6 0 0 :::80 :::* LISTEN 31045/nginx.conf
# netstat -ltnp | grep 443
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 31045/nginx.conf
And throwing in the process output for good measure…
# ps -aux | grep nginx
root 25934 0.0 0.0 12948 1016 pts/0 S+ 15:21 0:00 grep --color=auto nginx
root 31045 0.0 0.3 126944 3452 ? Ss Sep02 0:00 nginx: master process nginx -c /etc/nginx/nginx.conf
www-data 31053 0.0 0.5 127096 6072 ? S Sep02 0:12 nginx: worker process
Kill those processes and then try again. If it makes it any easier then use htop for this.
You probably have another process listening on ports 80 and 443, paste the output of these two commands to check:
netstat -ltnp | grep 80 and netstat -ltnp | grep 443
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.