# [SOLVED] Apache:Cannot assign requested address,bind to port

## dragos240

Hello,

I can't get apache to use my server's name, it also doesn't want to bind to port 80. Here's the error on startup:

```
 * Starting apache2 ...

apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

(99)Cannot assign requested address: make_sock: could not bind to address 24.61.157.141:80

no listening sockets available, shutting down

Unable to open logs                                                      [ !! ]

 * ERROR: apache2 failed to start

```

Help appreciated.

Thanks,

Dragos240Last edited by dragos240 on Fri Jun 03, 2011 5:13 pm; edited 1 time in total

----------

## davidm

First things first, is that the correct IP and is there something already binding to port 80 (use netstat to check)?  And just to check what are some details about this server and how it is connected.  Also it's not able to open the logs which is strange.  Do you have root on this server and have you done anything with the configuration files yet?  How are you invoking apache?

----------

## dragos240

 *davidm wrote:*   

> First things first, is that the correct IP and is there something already binding to port 80 (use netstat to check)?  And just to check what are some details about this server and how it is connected.  Also it's not able to open the logs which is strange.  Do you have root on this server and have you done anything with the configuration files yet?  How are you invoking apache?

 

netstat -ltnp:

```
Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    

tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      16422/mysqld        

tcp        0      0 0.0.0.0:10000           0.0.0.0:*               LISTEN      14731/perl          

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      19646/sshd          

tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      15017/cupsd         

tcp        0      0 0.0.0.0:17500           0.0.0.0:*               LISTEN      10692/dropbox       

tcp6       0      0 :::22                   :::*                    LISTEN      19646/sshd          

tcp6       0      0 ::1:631                 :::*                    LISTEN      15017/cupsd         

tcp6       0      0 :::25565                :::*                    LISTEN      22273/java
```

Nothing on port 80.

My previous config broke for some reason, and was giving the same errors. I then deleted all apache conf files are re-emerged apache. I did this to delete the config files:

rm -r /etc/apache2/

rm /etc/conf.d/apache2

The server after emerge ran fine but still gave this error:

```
* Starting apache2 ...

apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName 
```

After adding a Listen option which I told to attach to my server IP and port 80, this happens. When I just have it listen on port 80 alone it does this:

"Could not bind to port: 80" or something similar.

Also before editing the conf files, localhost can access the server on 127.0.0.1 and the local ip: 192.168.1.101, but other people on LAN cannot access it on 192.168.1.101

I know my ISP is not blocking port 80, and I'm 100% positive that's my IP, I use it for other services I use daily.

Also, is that Zorak from The Brak Show?

Thanks,

Dragos240

----------

## davidm

The 'ServerName' directive should get rid of the message about getting the Fully qualified domain name.

If you can post some of your apache2 conf files (modify the IP's a little if you want for privacy) just to see what you have.  If this is a home connection and you are using the external IP address for the listen directive then it would make sense that other people can't access it on the LAN possibly due to NAT issues depending on how you have things configured.

Yep it's Zorak from Space Ghost Coast To Coast.  :Smile: 

Also a thought- If you are trying to access it from outside using an external IP using port 80 also make sure there isn't any sort of server running already on port 80 such as on your router's remote management.  That would not show up on netstat.  I'm guessing this is a home network and not on a remote server somewhere, right?

----------

## KWhat

 *Quote:*   

> My previous config broke for some reason, and was giving the same errors. I then deleted all apache conf files are re-emerged apache ... 

 

Generally when an Apache config breaks for some reason it was because of an upgrade.  Most likely it was the default virtual host config files.  

 *Quote:*   

> Also before editing the conf files, localhost can access the server on 127.0.0.1 and the local ip: 192.168.1.101, but other people on LAN cannot access it on 192.168.1.101 

 

You cannot bind to what i am assuming is your external ip address (24.61.157.141) behind the router.  Change that ip in your config file to the ip address assigned to eth0 and setup your nat properly.  You can usually forward an http alt port like 8080 or 8000 to NAT to port 80 at 192.168.1.101.

----------

## dragos240

Ah that makes sense. I wasn't sure how that worked entirely. I'll see how that works and get back to you.

----------

## dragos240

I changed the port to 8000 and I have no-ip, it can redirect a certain port to port 80 for me.

It starts now, but a different error arose. I can't access anything on the server. It gives me a 403 Forbidden.

----------

## KWhat

Post the error you are getting in the /var/log/apache/error log.

----------

## dragos240

 *KWhat wrote:*   

> Post the error you are getting in the /var/log/apache/error log.

 

This appears to be the 403 Forbidden error in the log:

```
[Fri Jun 03 11:56:48 2011] [error] [client 173.13.89.145] client denied by server configuration: /usr/htdocs
```

----------

## dragos240

I created a new vhost and it fixed itself. Solved.

----------

## yupan

you can try ,then delete file httpd.conf about :Listen 24.61.157.141:80

----------

