Address already in use: make_sock: could not bind to port 80/443

This error occurs for one of two reasons. Either you are not root or another application is already using the port(s) Apache wants to use. If you are not root and do not have administrative access to the machine, you must change the Apache configuration to use another port as described below.

 

HTTP normally binds to port 80; HTTPS normally binds to port 443. Similar errors can occur if port 443 is already in use when Apache with HTTPS is trying to start.

 

To find out which, if any, application is already using the port(s) in question run netstat -tlnp | egrep ":80 |:443 " as root. If the command returns no output then no applications are using either port 80 or 443, which means Apache should have a no problem binding to the port(s) it needs.

 

However, if output is returned, look to the far right of each row of output for the PID and name of the executable. This will give you an indication of what process is currently using the port. The quick and dirty solution is to run kill , where is the PID of the process(es) using the ports needed by Apache. A more elegant solution would be to find out how the application currently using the port got started and prevent it from starting.

 

If ports 80 and/or 443 are in use or you do not have root access, another solution is to change which port(s) Apache uses. This will produce a non-standard configuration, but will circumvent the issue where ports 80 and 443 are already in use. Doing so requires the modification of the file /etc/httpd/conf/httpd.conf . The LISTEN directive specifies which port (80, by default) on which Apache will listen for HTTP requests. Similarly, the file /etc/httpd/conf.d/ssl.conf also has a LISTEN directive which specifies the port (443, by default) on which Apache will listen for HTTPS requests. Using your favorite text editor, change the value to an unused port number and [re]start the Apache service.

 

For example, in /etc/httpd/conf/httpd.conf , change the line


Listen 0.0.0.0:80

to

Listen 0.0.0.0:XXXX
 

where XXXX is an unused port. Then [re]start Apache/HTTPD by typing either

service httpd restart
 

or

apachectl restart

 

If Apache was not previously running you can safely ignore any errors indicating that HTTPD could not be stopped. Note that if you add 443 to the list of available addresses in the main tab of the Apache configuration tool system-config-httpd (redhat-config-httpd) in Red hat Enterprise Linux 3 and below) and enable SSL you might get errors since the SSL directive conflicts with this port.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值