I wanted to serve my website over https and thus I followed this tutorial exactly as given.

On step 5 sudo nginx -t gave positive results as configuration was OK. When I ran sudo systemctl restart nginx it gave the following error

Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

When I checked the error logs at /var/log/nginx/error.log if showed this error

2017/03/14 07:35:20 [emerg] 12111#12111: bind() to 0.0.0.0:443 failed (98: Address already in use)

2017/03/14 07:35:20 [emerg] 12111#12111: bind() to 0.0.0.0:443 failed (98: Address already in use)

2017/03/14 07:35:20 [emerg] 12111#12111: bind() to 0.0.0.0:443 failed (98: Address already in use)

2017/03/14 07:35:20 [emerg] 12111#12111: bind() to 0.0.0.0:443 failed (98: Address already in use)

2017/03/14 07:35:20 [emerg] 12111#12111: bind() to 0.0.0.0:443 failed (98: Address already in use)

2017/03/14 07:35:20 [emerg] 12111#12111: still could not bind()

After tried with tricks like including ipv6only=on, apparently nothing seemed to work and now I am clueless what to do?

My default configuration is available here

Please help

  • that looks as if another process opened port tcp/443 and nginx fails to do so because of this. did you check netstat for an already opened port 443? – Phillip -Zyan K Lee- Stockmann Mar 14 '17 at 14:51
  • It looks like openvpn was already using the port 443. Now it's working fine. – Harshit Agrawal Mar 14 '17 at 14:57
  • you are most welcome. – Phillip -Zyan K Lee- Stockmann Mar 14 '17 at 14:59
up vote 1 down vote accepted

that looks as if another process opened port tcp/443 and nginx fails to do so because of this. did you check netstat for an already opened port 443?

The problem is, you had this in your config:

listen 80 default_server;
listen [::]:80 default_server;

This does the following:

1 - I start the server on port 80

Result: OK

2 - I start the server on port [::]:80

Result: FAILED

I think with your 2nd line, you are actually calling a listen parameter on both ivp4 and ipv6. Try the following:

listen 80 default_server;
listen [::]:80 ipv6only=on;

See if it works or not.

BTW, you are also missing some very important rows in the config. Namely:

ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.