# [solved] rc fails to start dovecot and nginx

## skiwarz

I have a server running nginx, postfix, and dovecot. Whenever I restart the system, I get this error:

```
 * Bringing up interface enp0s25

 *   dhcp ...

 *     Running dhcpcd ...

enp0s25: waiting for carrier

enp0s25: carrier acquired

enp0s25: adding address xxxxxxxxxx

DUID xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

enp0s25: IAID xxxxxxxxxxx

enp0s25: rebinding lease of xxxxxxxxxxxxxx

enp0s25: soliciting an IPv6 router

enp0s25: Router Advertisement from xxxxxxxxxxxxxxxxxxxxxxx

enp0s25: adding address xxxxxxxxxxxxxxxxxxxxxxxxxxx

enp0s25: adding route to xxxxxxxxxxxxxxxxx

enp0s25: adding default route via xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

enp0s25: requesting DHCPv6 information

forked to background, child pid xxxx

 [ ok ]

 *     received address 

 [ ok ]

 * Starting dovecot ...

Error: bind(xxxxxxxxxxxxx) failed: Cannot assign requested address

Error: service(imap-login): listen(xxxxxxxxxxxxxxx) failed: Cannot assign requested address

Error: bind(xxxxxxxxxxxxxxxx) failed: Cannot assign requested address

Error: service(imap-login): listen(xxxxxxxxxxxxxxxxxx) failed: Cannot assign requested address

Fatal: Failed to start listeners

 * start-stop-daemon: failed to start `/usr/sbin/dovecot'

 [ !! ]

 * ERROR: dovecot failed to start

 * Starting murmur ...

 [ ok ]

 * Mounting network filesystems ...

 [ ok ]

 * Checking nginx' configuration ...

nginx: [emerg] bind() to xxxxxxxxxxxxxxxx failed (99: Cannot assign requested address)

nginx: configuration file /etc/nginx/nginx.conf test failed

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: [emerg] bind() to xxxxxxxxxxxxxxxx failed (99: Cannot assign requested address)

nginx: configuration file /etc/nginx/nginx.conf test failed

 * failed, please correct errors above

 [ !! ]

 * ERROR: nginx failed to start

 * Starting postfix  ...

 [ ok ]

```

Dovecot and nginx fail at different times. That is, sometimes one of them will start and one fails, or else they will both fail. I can manually start them after logging in, using "/etc/init.d/[dovecot or nginx] start" and it works just fine.

I have both of these services set to 

```
listen=xxxxxxxxxx
```

 in their appropriate config files.

To me it seems like rc is starting them before dhcpcd has completed its setup of the network.

Any suggestions?Last edited by skiwarz on Wed May 11, 2016 6:07 am; edited 1 time in total

----------

## skiwarz

I switched over to a static ip, and everything works now. So I think dhcpcd just didn't have enough time to get the ip assigned.

If anyone cares, I used this guide to set up static ips: https://wiki.gentoo.org/wiki/Handbook:X86/Full/Networking

----------

