Trying to restart NGINX service, you receive an error stating systemd[1]: Failed to start The NGINX HTTP and reverse proxy server.
Another line will state the possible cause of the error, for example vpsxxxxx.inmotionhosting.com nginx[9082]: nginx: [emerg] a duplicate listen xxx.xxx.xxx.xxx:80 in /etc/nginx/conf.d/default.conf:29
Duplicate line errors with NGINX typically occur when the same configuration directive is defined more than once in the NGINX configuration file. This redundancy can lead to unexpected behavior, potential conflicts, and misconfigurations in the web server. When NGINX parses the configuration, it enforces a strict one-directive per parameter approach, and encountering duplicates can trigger errors during server startup or configuration reload. To resolve these issues, administrators should carefully review their NGINX configuration files, identify and remove any duplicate lines, ensuring the server operates smoothly and efficiently.
Update Configuration
IMPORTANT: This solution will require root access. If this needs to be obtained, follow the guide on requesting root access.
CAUTION: These steps are for NGINX installations not provided by InMotion Hosting. This process and providing support on this issue is out of scope and requiring a third-party developer will be required for further assistance. If this error occurs on the InMotion Hosting NGINX installation, please reach out to our Technical Support team for assistance.
- SSH into the server as root
- Edit
/etc/nginx/conf.d/default.confwith your preferred text editor
EXAMPLE: For example, to edit the file using nano, runnano /etc/nginx/conf.d/default.conf. - Locate the line causing the error, as stated in the initial error message
EXAMPLE: In the example error message,/etc/nginx/conf.d/default.conf:29is line 29. - Confirm that the line is duplicated
TIP: Check for other lines with the same directive in the file. They may not be at the same location in the configuration file. - Comment out the duplicate lines within
/etc/nginx/conf.d/default.confusing#
EXAMPLE: If the duplicated line islisten 12.34.56.78:80, update it to#listen 12.34.56.78:80. - Save
/etc/nginx/conf.d/default.conf
TIP: Using nano, save and exit by pressing <Ctrl+X> followed by <Y> to save changes. - Restart the NGINX service using
service nginx restart
Comments
0 comments
Article is closed for comments.