httpd: could not bind to address 0.0.0.0:19999

Locked
User avatar
Mihai Romania
Posts: 60
Joined: 2023 May 03, 14:12
Location: ROMANIA
Contact:

httpd: could not bind to address 0.0.0.0:19999

Post by Mihai »

After adding the port 19999 in the configuration file (httpd.conf) when restarting the web server (httpd) the following error is observed

Code: Select all

[root @ CentOS ~]$ systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2019-01-28 16:16:22 EET; 9s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 11451 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 15626 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited, status=0/SUCCESS)
  Process: 11450 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 11450 (code=exited, status=1/FAILURE)

Jan 28 16:16:22 web.127001.ro httpd[11450]: (13)Permission denied: AH00072: make_sock: could not bind to address [::]:19999
Jan 28 16:16:22 web.127001.ro httpd[11450]: (13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:19999
Jan 28 16:16:22 web.127001.ro httpd[11450]: no listening sockets available, shutting down
Jan 28 16:16:22 web.127001.ro httpd[11450]: AH00015: Unable to open logs
Jan 28 16:16:22 web.127001.ro systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Jan 28 16:16:22 web.127001.ro kill[11451]: kill: cannot find process ""
Jan 28 16:16:22 web.127001.ro systemd[1]: httpd.service: control process exited, code=exited status=1
Jan 28 16:16:22 web.127001.ro systemd[1]: Failed to start The Apache HTTP Server.
Jan 28 16:16:22 web.127001.ro systemd[1]: Unit httpd.service entered failed state.
Jan 28 16:16:22 web.127001.ro systemd[1]: httpd.service failed.
The solution is done by adding port 19999 in SELinux Policy Management as follows

Code: Select all

[root @ CentOS ~]$ semanage port -a -t http_port_t -p tcp 19999
Restart httpd service

Code: Select all

[root @ CentOS ~]$ systemctl restart httpd.service
Check httpd.service status

Code: Select all

[root @ CentOS ~]$ systemctl status httpd.service
Active: active (running) since Mon 2019-01-28 16:18:45 EET; 1min 34s ago

Jan 28 16:18:45 web.127001.ro systemd[1]: Stopped The Apache HTTP Server.
Jan 28 16:18:45 web.127001.ro systemd[1]: Starting The Apache HTTP Server...
Jan 28 16:18:45 web.127001.ro systemd[1]: Started The Apache H
Check if port 19999 has been added to SELinux

Code: Select all

[root @ CentOS ~]$ semanage port -l | grep ^http_port_t
http_port_t                    tcp      19999, 80, 81, 443, 488, 8008, 8009, 8443, 9000
To delete the port from SELinux execute the following command

Code: Select all

[root @ CentOS ~]$ semanage port --delete -t http_port_t -p tcp 19999
222222

Check if port 19999 has been deleted from SELinux

Code: Select all

[root @ CentOS ~]$ semanage port -l | grep ^http_port_t
http_port_t                    tcp      80, 81, 443, 488, 8008, 8009, 8443, 9000
I'm on LinkedIn
Locked