# Fab restart\_services: brings an error

**URL:** <https://forum.dimagi.com/t/fab-restart-services-brings-an-error/9194>\
**Category:** Developers\
**Created:** [August 15, 2022, 4:15pm UTC](https://forum.dimagi.com/t/fab-restart-services-brings-an-error/9194 "2022-08-15T16:15:59Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![demis08](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/demis08/32/1234_2.png) [@demis08](https://forum.dimagi.com/u/demis08)\
**Post date:** [August 15, 2022, 4:15pm UTC](https://forum.dimagi.com/t/fab-restart-services-brings-an-error/9194/1 "2022-08-15T16:15:59Z")

</div>

Hello,

the following is an error while running the following command: "cchq fab restart\_services". the same error appears during redeployment using the command "cchq deploy"

```auto
172.19.3.41] out: [62/1977]
                                                                                                             
[172.19.3.41] sudo: nginx -s reload                                                                        
[172.19.3.41] out: nginx: [warn] conflicting server name "www.echisethiopia.org" on 0.0.0.0:80, ignored   
[172.19.3.41] out: nginx: [warn] conflicting server name "www.echisethiopia.org" on 0.0.0.0:443, ignored
[172.19.3.41] out:                                                                                         
                                                                                                                      
[172.19.3.38] Executing task 'restart_webworkers'                                                      
[172.19.3.41] Executing task '_decommission_host'                                                                    
[172.19.3.41] sudo: sed -i.bak -r -e 's/^([]*server[]+172.19.3.38)/#\1/g' "$(echo /etc/nginx/sites-available/echis_commcare)"
[172.19.3.41] sudo: nginx -t                                                                                              
[172.19.3.41] out: nginx: [emerg] no servers are inside upstream in /etc/nginx/sites-enabled/echis_commcare:29        
[172.19.3.41] out: nginx: configuration file /etc/nginx/nginx.conf test failed                                             
[172.19.3.41] out:

Fatal error: sudo() received nonzero return code 1 while executing!
Requested: nginx -t
Executed: sudo -S -p 'sudo password:' -H -u "root" nginx -t

Aborting.
Traceback (most recent call last):
  File "/home/ansible/.virtualenvs/cchq/lib/python3.6/site-packages/fabric/main.py", line 749, in main
    *args, **kwargs
  File "/home/ansible/.virtualenvs/cchq/lib/python3.6/site-packages/fabric/tasks.py", line 385, in execute
    multiprocessing
  File "/home/ansible/.virtualenvs/cchq/lib/python3.6/site-packages/fabric/tasks.py", line 275, in _execute
    return task.run(*args, **kwargs)
  File "/home/ansible/.virtualenvs/cchq/lib/python3.6/site-packages/fabric/tasks.py", line 172, in run
    return self.wrapped(*args, **kwargs)
  File "/home/ansible/commcare-cloud/src/commcare_cloud/fab/fabfile.py", line 542, in deploy_commcare
    _deploy_without_asking(skip_record)
  File "/home/ansible/commcare-cloud/src/commcare_cloud/fab/fabfile.py", line 420, in _deploy_without_asking
    silent_services_restart()
  File "/home/ansible/commcare-cloud/src/commcare_cloud/fab/fabfile.py", line 582, in silent_services_restart
execute(supervisor.restart_webworkers)
  File "/home/ansible/.virtualenvs/cchq/lib/python3.6/site-packages/fabric/tasks.py", line 385, in execute
    multiprocessing
  File "/home/ansible/.virtualenvs/cchq/lib/python3.6/site-packages/fabric/tasks.py", line 275, in _execute
    return task.run(*args, **kwargs)
  File "/home/ansible/.virtualenvs/cchq/lib/python3.6/site-packages/fabric/tasks.py", line 172, in run
    return self.wrapped(*args, **kwargs)
  File "/home/ansible/.virtualenvs/cchq/lib/python3.6/site-packages/fabric/decorators.py", line 52, in inner_decorator
    return func(*args, **kwargs)
  File "/home/ansible/commcare-cloud/src/commcare_cloud/fab/operations/supervisor.py", line 100, in restart_webworkers
    with decommissioned_host(env.host):
  File "/usr/lib/python3.6/contextlib.py", line 81, in __enter__
    return next(self.gen)
  File "/home/ansible/commcare-cloud/src/commcare_cloud/fab/operations/supervisor.py", line 89, in decommissioned_host
    execute(_decommission_host, host)
  File "/home/ansible/.virtualenvs/cchq/lib/python3.6/site-packages/fabric/tasks.py", line 385, in execute
    multiprocessing
  File "/home/ansible/.virtualenvs/cchq/lib/python3.6/site-packages/fabric/tasks.py", line 275, in _execute
return task.run(*args, **kwargs)
  File "/home/ansible/.virtualenvs/cchq/lib/python3.6/site-packages/fabric/tasks.py", line 172, in run
    return self.wrapped(*args, **kwargs)
  File "/home/ansible/.virtualenvs/cchq/lib/python3.6/site-packages/fabric/decorators.py", line 52, in inner_decorator
    return func(*args, **kwargs)
  File "/home/ansible/commcare-cloud/src/commcare_cloud/fab/operations/supervisor.py", line 66, in _decommission_host
    _check_and_reload_nginx()
  File "/home/ansible/commcare-cloud/src/commcare_cloud/fab/operations/supervisor.py", line 80, in _check_and_reload_nginx
    sudo('nginx -t', shell=False, user='root')
  File "/home/ansible/.virtualenvs/cchq/lib/python3.6/site-packages/fabric/network.py", line 654, in host_prompting_wrapper
    return func(*args, **kwargs)
  File "/home/ansible/.virtualenvs/cchq/lib/python3.6/site-packages/fabric/operations.py", line 1121, in sudo
    stderr=stderr, timeout=timeout, shell_escape=shell_escape,
  File "/home/ansible/.virtualenvs/cchq/lib/python3.6/site-packages/fabric/operations.py", line 952, in _run_command
    error(message=msg, stdout=out, stderr=err)
  File "/home/ansible/.virtualenvs/cchq/lib/python3.6/site-packages/fabric/utils.py", line 359, in error
    return func(message)
  File "/home/ansible/.virtualenvs/cchq/lib/python3.6/site-packages/fabric/utils.py", line 55, in abort
raise env.abort_exception(msg)
Exception: sudo() received nonzero return code 1 while executing!

Requested: nginx -t
Executed: sudo -S -p 'sudo password:' -H -u "root" nginx -t
Disconnecting from 172.19.4.35... done.
Disconnecting from 172.19.3.41... done.
Disconnecting from 172.19.4.42... done.

```

---

<div class="post-metadata">

**Author:** ![Sravan\_Reddy](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@Sravan\_Reddy](https://forum.dimagi.com/u/Sravan_Reddy)\
**Post date:** [August 16, 2022, 7:01am UTC](https://forum.dimagi.com/t/fab-restart-services-brings-an-error/9194/2 "2022-08-16T07:01:51Z")

</div>

Hello Demis

According to the traceback given (highlighted below), it looks like there is an issue with your nginx config. You can manually run `sudo nginx -t` command on your proxy/nginx machine to see what the issue is.

> [@demis08](#):
>
> ```auto
> [172.19.3.41] sudo: nginx -t                                                                                              
> [172.19.3.41] out: nginx: [emerg] no servers are inside upstream in /etc/nginx/sites-enabled/echis_commcare:29        
> [172.19.3.41] out: nginx: configuration file /etc/nginx/nginx.conf test failed                                             
> [172.19.3.41] out:
> 
> ```

---

<div class="post-metadata">

**Author:** ![demis08](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/demis08/32/1234_2.png) [@demis08](https://forum.dimagi.com/u/demis08)\
**Post date:** [August 16, 2022, 9:03am UTC](https://forum.dimagi.com/t/fab-restart-services-brings-an-error/9194/3 "2022-08-16T09:03:25Z")

</div>

Hi Sravan,

yes, the nginx test failed due to the change made by `fab restart service`. it comments on the `server 172.19.3.38:8181;` as shown below

> upstream echis\_formplayer {  
> zone echis\_formplayer 256k;
> 
> ```
> hash $cookie_formplayer_session$http_x_formplayer_session consistent;
> 
> ```
> 
> #server 172.19.3.38:8181;  
> }

---

<div class="post-metadata">

**Author:** ![Sravan\_Reddy](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@Sravan\_Reddy](https://forum.dimagi.com/u/Sravan_Reddy)\
**Post date:** [August 17, 2022, 8:36am UTC](https://forum.dimagi.com/t/fab-restart-services-brings-an-error/9194/4 "2022-08-17T08:36:39Z")

</div>

If you have manually edited the nginx, please make sure you haven't broken the configuration. If you want to rollback to normal, you can do `cchq <env> ap deploy_proxy.yml`

---

<div class="post-metadata">

**Author:** ![demis08](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/demis08/32/1234_2.png) [@demis08](https://forum.dimagi.com/u/demis08)\
**Post date:** [August 17, 2022, 8:40am UTC](https://forum.dimagi.com/t/fab-restart-services-brings-an-error/9194/5 "2022-08-17T08:40:44Z")

</div>

Hi Sravan,

the Nginx configuration is not edited manually, and `cchq <env> ap deploy_proxy.yml ` task works properly.

The issue every time I run the script ` fab restart_services` , it tries to edit the nginx config and completes with the above error.

---

<div class="post-metadata">

**Author:** ![Sravan\_Reddy](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@Sravan\_Reddy](https://forum.dimagi.com/u/Sravan_Reddy)\
**Post date:** [August 22, 2022, 8:28am UTC](https://forum.dimagi.com/t/fab-restart-services-brings-an-error/9194/6 "2022-08-22T08:28:18Z")

</div>

> [@demis08](#):
>
> it tries to edit the nginx config

Does the config get edited, can you please share what gets updated?

---

<div class="post-metadata">

**Author:** ![demis08](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/demis08/32/1234_2.png) [@demis08](https://forum.dimagi.com/u/demis08)\
**Post date:** [August 22, 2022, 9:41am UTC](https://forum.dimagi.com/t/fab-restart-services-brings-an-error/9194/7 "2022-08-22T09:41:42Z")

</div>

> upstream echis\_formplayer {  
> zone echis\_formplayer 256k;
> 
> hash $cookie\_formplayer\_session$http\_x\_formplayer\_session consistent;  
> #server 172.19.3.38:8181;  
> }

this line commented #server 172.19.3.38:8181;

---

<div class="post-metadata">

**Author:** ![CharlSmit](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@CharlSmit](https://forum.dimagi.com/u/CharlSmit)\
**Post date:** [August 23, 2022, 3:29pm UTC](https://forum.dimagi.com/t/fab-restart-services-brings-an-error/9194/8 "2022-08-23T15:29:59Z")

</div>

@demis08 Do you only have one webworker?

---

<div class="post-metadata">

**Author:** ![demis08](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/demis08/32/1234_2.png) [@demis08](https://forum.dimagi.com/u/demis08)\
**Post date:** [August 23, 2022, 3:57pm UTC](https://forum.dimagi.com/t/fab-restart-services-brings-an-error/9194/9 "2022-08-23T15:57:04Z")

</div>

No, we have 3 web workers as shown below.

> [webworkers:children]  
> echis\_server5  
> echis\_server7  
> echis\_server35

---

<div class="post-metadata">

**Author:** ![CharlSmit](https://dimagi.b-cdn.net/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@CharlSmit](https://forum.dimagi.com/u/CharlSmit)\
**Post date:** [August 24, 2022, 9:49am UTC](https://forum.dimagi.com/t/fab-restart-services-brings-an-error/9194/10 "2022-08-24T09:49:54Z")

</div>

@demis08 Have you also followed [these](https://commcare-cloud.readthedocs.io/en/latest/reference/firefighting/general.html#nginx) steps?

---

<div class="post-metadata">

**Author:** ![demis08](https://dimagi.b-cdn.net/user_avatar/forum.dimagi.com/demis08/32/1234_2.png) [@demis08](https://forum.dimagi.com/u/demis08)\
**Post date:** [September 19, 2022, 1:01pm UTC](https://forum.dimagi.com/t/fab-restart-services-brings-an-error/9194/11 "2022-09-19T13:01:08Z")

</div>

hello @Sravan_Reddy and @CharlSmit

recently found that the error is not related to the fab script. it's related to 'users` on a single host.

I created a new post here: [Getting an error on bootstrap-users](https://forum.dimagi.com/t/getting-an-error-on-bootstrap-users/9312)
