# Plotly - orca ConnectionRefusedError

**URL:** <https://community.plotly.com/t/plotly-orca-connectionrefusederror/19723>\
**Category:** 📊 Plotly Python\
**Created:** [February 18, 2019, 1:10pm UTC](https://community.plotly.com/t/plotly-orca-connectionrefusederror/19723 "2019-02-18T13:10:57Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![claudia](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@claudia](https://community.plotly.com/u/claudia)\
**Post date:** [February 18, 2019, 1:10pm UTC](https://community.plotly.com/t/plotly-orca-connectionrefusederror/19723/1 "2019-02-18T13:10:57Z")

</div>

My example :

import plotly  
plotly. **version**

from plotly.offline import iplot, init\_notebook\_mode  
import plotly.graph\_objs as go  
import [plotly.io](http://plotly.io) as pio

import os  
import numpy as np

init\_notebook\_mode(connected=True)

N = 100  
x = np.random.rand(N)  
y = np.random.rand(N)  
colors = np.random.rand(N)  
sz = np.random.rand(N)\*30

fig = go.Figure()  
fig.add\_scatter(x=x,  
y=y,  
mode=‘markers’,  
marker={‘size’: sz,  
‘color’: colors,  
‘opacity’: 0.6,  
‘colorscale’: ‘Viridis’  
});  
iplot(fig)

if not os.path.exists(‘images’):  
os.mkdir(‘images’)

pio.write\_image(fig, ‘images/fig1.png’)

* * *

only works on a single user, it is curious because it is with the user that I executed it first.  
I installed orca, plotly (the installation is from a docker, everything installed globally, pip install and so on) as it appears on the official page, orca --help in the terminal works for me, without any error.  
If I do it in that user if I execute the code correctly, but if I execute it in any other, it does not work and I get the following error :

* * *

ConnectionRefusedError Traceback (most recent call last)  
/opt/conda/lib/python3.6/site-packages/urllib3/connection.py in \_new\_conn(self)  
170 conn = connection.create\_connection(  
–\> 171 (self.\_dns\_host, self.port), self.timeout, \*\*extra\_kw)  
172

/opt/conda/lib/python3.6/site-packages/urllib3/util/connection.py in create\_connection(address, timeout, source\_address, socket\_options)  
78 if err is not None:  
—\> 79 raise err  
80

/opt/conda/lib/python3.6/site-packages/urllib3/util/connection.py in create\_connection(address, timeout, source\_address, socket\_options)  
68 sock.bind(source\_address)  
—\> 69 sock.connect(sa)  
70 return sock

ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

NewConnectionError Traceback (most recent call last)  
/opt/conda/lib/python3.6/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert\_same\_host, timeout, pool\_timeout, release\_conn, chunked, body\_pos, \*\*response\_kw)  
599 body=body, headers=headers,  
–\> 600 chunked=chunked)  
601

/opt/conda/lib/python3.6/site-packages/urllib3/connectionpool.py in \_make\_request(self, conn, method, url, timeout, chunked, \*\*httplib\_request\_kw)  
353 else:  
–\> 354 conn.request(method, url, \*\*httplib\_request\_kw)  
355

/opt/conda/lib/python3.6/http/client.py in request(self, method, url, body, headers, encode\_chunked)  
1238 “”“Send a complete request to the server.”""  
-\> 1239 self.\_send\_request(method, url, body, headers, encode\_chunked)  
1240

/opt/conda/lib/python3.6/http/client.py in \_send\_request(self, method, url, body, headers, encode\_chunked)  
1284 body = \_encode(body, ‘body’)  
-\> 1285 self.endheaders(body, encode\_chunked=encode\_chunked)  
1286

/opt/conda/lib/python3.6/http/client.py in endheaders(self, message\_body, encode\_chunked)  
1233 raise CannotSendHeader()  
-\> 1234 self.\_send\_output(message\_body, encode\_chunked=encode\_chunked)  
1235

/opt/conda/lib/python3.6/http/client.py in \_send\_output(self, message\_body, encode\_chunked)  
1025 del self.\_buffer[:]  
-\> 1026 self.send(msg)  
1027

/opt/conda/lib/python3.6/http/client.py in send(self, data)  
963 if self.auto\_open:  
–\> 964 self.connect()  
965 else:

/opt/conda/lib/python3.6/site-packages/urllib3/connection.py in connect(self)  
195 def connect(self):  
–\> 196 conn = self.\_new\_conn()  
197 self.\_prepare\_conn(conn)

/opt/conda/lib/python3.6/site-packages/urllib3/connection.py in \_new\_conn(self)  
179 raise NewConnectionError(  
–\> 180 self, “Failed to establish a new connection: %s” % e)  
181

NewConnectionError: \<urllib3.connection.HTTPConnection object at 0x7f465ce420b8\>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

MaxRetryError Traceback (most recent call last)  
/opt/conda/lib/python3.6/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)  
444 retries=self.max\_retries,  
–\> 445 timeout=timeout  
446 )

/opt/conda/lib/python3.6/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert\_same\_host, timeout, pool\_timeout, release\_conn, chunked, body\_pos, \*\*response\_kw)  
637 retries = retries.increment(method, url, error=e, \_pool=self,  
–\> 638 \_stacktrace=sys.exc\_info()[2])  
639 retries.sleep()

/opt/conda/lib/python3.6/site-packages/urllib3/util/retry.py in increment(self, method, url, response, error, \_pool, \_stacktrace)  
397 if new\_retry.is\_exhausted():  
–\> 398 raise MaxRetryError(\_pool, url, error or ResponseError(cause))  
399

MaxRetryError: HTTPConnectionPool(host=‘localhost’, port=36785): Max retries exceeded with url: / (Caused by NewConnectionError(’\<urllib3.connection.HTTPConnection object at 0x7f465ce420b8\>: Failed to establish a new connection: [Errno 111] Connection refused’,))

During handling of the above exception, another exception occurred:

ConnectionError Traceback (most recent call last)  
/opt/conda/lib/python3.6/site-packages/plotly/io/\_orca.py in to\_image(fig, format, width, height, scale, validate)  
1324 width=width,  
-\> 1325 height=height)  
1326 except OSError as err:

/opt/conda/lib/python3.6/site-packages/retrying.py in wrapped\_f(\*args, \*\*kw)  
48 def wrapped\_f(\*args, \*\*kw):  
—\> 49 return Retrying(\*dargs, \*\*dkw).call(f, \*args, \*\*kw)  
50

/opt/conda/lib/python3.6/site-packages/retrying.py in call(self, fn, \*args, \*\*kwargs)  
211 # get() on an attempt with an exception should cause it to be raised, but raise just in case  
–\> 212 raise attempt.get()  
213 else:

/opt/conda/lib/python3.6/site-packages/retrying.py in get(self, wrap\_exception)  
246 else:  
–\> 247 six.reraise(self.value[0], self.value[1], self.value[2])  
248 else:

/opt/conda/lib/python3.6/site-packages/six.py in reraise(tp, value, tb)  
692 raise value.with\_traceback(tb)  
–\> 693 raise value  
694 finally:

/opt/conda/lib/python3.6/site-packages/retrying.py in call(self, fn, \*args, \*\*kwargs)  
199 try:  
–\> 200 attempt = Attempt(fn(\*args, \*\*kwargs), attempt\_number, False)  
201 except:

/opt/conda/lib/python3.6/site-packages/plotly/io/\_orca.py in request\_image\_with\_retrying(\*\*kwargs)  
1231 json\_str = json.dumps(request\_params, cls=plotly.utils.PlotlyJSONEncoder)  
-\> 1232 response = requests.post(server\_url + ‘/’, data=json\_str)  
1233 return response

/opt/conda/lib/python3.6/site-packages/requests/api.py in post(url, data, json, \*\*kwargs)  
111  
–\> 112 return request(‘post’, url, data=data, json=json, \*\*kwargs)  
113

/opt/conda/lib/python3.6/site-packages/requests/api.py in request(method, url, \*\*kwargs)  
57 with sessions.Session() as session:  
—\> 58 return session.request(method=method, url=url, \*\*kwargs)  
59

/opt/conda/lib/python3.6/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow\_redirects, proxies, hooks, stream, verify, cert, json)  
511 send\_kwargs.update(settings)  
–\> 512 resp = self.send(prep, \*\*send\_kwargs)  
513

/opt/conda/lib/python3.6/site-packages/requests/sessions.py in send(self, request, \*\*kwargs)  
621 # Send the request  
–\> 622 r = adapter.send(request, \*\*kwargs)  
623

/opt/conda/lib/python3.6/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)  
512  
–\> 513 raise ConnectionError(e, request=request)  
514

ConnectionError: HTTPConnectionPool(host=‘localhost’, port=36785): Max retries exceeded with url: / (Caused by NewConnectionError(’\<urllib3.connection.HTTPConnection object at 0x7f465ce420b8\>: Failed to establish a new connection: [Errno 111] Connection refused’,))

During handling of the above exception, another exception occurred:

ValueError Traceback (most recent call last)  
 in   
49  
50  
—\> 51 pio.write\_image(fig, ‘images/fig1.png’)  
52  
53

/opt/conda/lib/python3.6/site-packages/plotly/io/\_orca.py in write\_image(fig, file, format, scale, width, height, validate)  
1510 width=width,  
1511 height=height,  
-\> 1512 validate=validate)  
1513  
1514 # Open file

/opt/conda/lib/python3.6/site-packages/plotly/io/\_orca.py in to\_image(fig, format, width, height, scale, validate)  
1340  
1341 {info}  
-\> 1342 “”".format(info=status\_str))  
1343 else:  
1344 # Reset the status so that if the user tries again, we’ll try to

ValueError:  
For some reason plotly.py was unable to communicate with the  
local orca server process, even though the server process seems to be running.

Please review the process and connection information below:

## orca status

```
state: running
executable: /opt/conda/bin/orca
version: 1.2.1
port: 36785
pid: 2935
command: ['/opt/conda/bin/orca', 'serve', '-p', '36785', '--plotly', '/opt/conda/lib/python3.6/site-packages/plotly/package_data/plotly.min.js', '--graph-only', '--mathjax', 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js']

```

I don’t understand why it works for one user and not for the others.  
Thanks.

---

<div class="post-metadata">

**Author:** ![jmmease](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmmease/32/3706_2.png) [@jmmease](https://community.plotly.com/u/jmmease)\
**Post date:** [February 19, 2019, 10:49am UTC](https://community.plotly.com/t/plotly-orca-connectionrefusederror/19723/2 "2019-02-19T10:49:55Z")

</div>

Hi @claudia,

I don’t have any initial ideas of what might be causing this. Is everything you’re doing running inside the docker container? Are there any firewall-style settings that might be restricting open ports? You could try launching orca from the command line with the `--debug` flag and see if there is any difference in the output between doing so with the working verse non-working users. For your situation above, run this command from the terminal.

```nohighlight
$ /opt/conda/bin/orca serve -p 36785 --plotly /opt/conda/lib/python3.6/site-packages/plotly/package_data/plotly.min.js --graph-only --mathjax https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js --debug

```

-Jon

---

<div class="post-metadata">

**Author:** ![claudia](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@claudia](https://community.plotly.com/u/claudia)\
**Post date:** [February 19, 2019, 11:00am UTC](https://community.plotly.com/t/plotly-orca-connectionrefusederror/19723/3 "2019-02-19T11:00:11Z")

</div>

Thank you for answering,  
I have executed the command line that you gave me with the user that allows me and with the one that doesn’t, and with the user that doesn’t allow me I get the following error:

Spinning up server with pid: 1197  
{“severity”:“ERROR”,“textPayload”:“Error: EACCES: permission denied, open ‘/tmp/orca-build/index-42a834e5-1946-4aba-9258-f3740bf6e17e.html’”}

How can it be solved? thank you very much

---

<div class="post-metadata">

**Author:** ![claudia](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@claudia](https://community.plotly.com/u/claudia)\
**Post date:** [February 19, 2019, 11:01am UTC](https://community.plotly.com/t/plotly-orca-connectionrefusederror/19723/4 "2019-02-19T11:01:01Z")

</div>

Thank you for answering,  
I have executed the command line that you gave me with the user that allows me and with the one that doesn’t, and with the user that doesn’t allow me I get the following error:

Spinning up server with pid: 1197  
{“severity”:“ERROR”,“textPayload”:“Error: EACCES: permission denied, open ‘/tmp/orca-build/index-42a834e5-1946-4aba-9258-f3740bf6e17e.html’”}

How can it be solved? thank you very much

---

<div class="post-metadata">

**Author:** ![jmmease](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmmease/32/3706_2.png) [@jmmease](https://community.plotly.com/u/jmmease)\
**Post date:** [February 19, 2019, 1:05pm UTC](https://community.plotly.com/t/plotly-orca-connectionrefusederror/19723/5 "2019-02-19T13:05:57Z")

</div>

Hi @claudia,

That’s a helpful clue! Perhaps there is some issue with the permission on your `/tmp` directory (or an issue with how orca creates the `/tmp/orca-build` directory).

Could you try opening up the permissions on `/tmp/orca-build`. with `chmod 777 /tmp/orca-build`?

-Jon

---

<div class="post-metadata">

**Author:** ![claudia](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@claudia](https://community.plotly.com/u/claudia)\
**Post date:** [February 19, 2019, 1:30pm UTC](https://community.plotly.com/t/plotly-orca-connectionrefusederror/19723/6 "2019-02-19T13:30:45Z")

</div>

yes, thank you the answer was clear but I do not understand why in the /tmp/ is saved or run when installing, is there any way to change that?  
Thanks

---

<div class="post-metadata">

**Author:** ![jmmease](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmmease/32/3706_2.png) [@jmmease](https://community.plotly.com/u/jmmease)\
**Post date:** [February 19, 2019, 2:03pm UTC](https://community.plotly.com/t/plotly-orca-connectionrefusederror/19723/7 "2019-02-19T14:03:39Z")

</div>

> [@claudia](#):
>
> yes, thank you the answer was clear

Does that mean that changing the permissions allowed image export to work properly?

> [@claudia](#):
>
> but I do not understand why in the /tmp/ is saved or run when installing, is there any way to change that?

This is a file that orca uses as the entry point for the electron application. No, there’s no way to change that. It looks like there is something we might be able to do about the permission on the `orca-build` directory. If you confirm that changing those permissions manually removes the error then I’ll open an issue with the orca project to discuss what we can do in orca itself.

-Jon

---

<div class="post-metadata">

**Author:** ![claudia](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@claudia](https://community.plotly.com/u/claudia)\
**Post date:** [February 19, 2019, 2:46pm UTC](https://community.plotly.com/t/plotly-orca-connectionrefusederror/19723/8 "2019-02-19T14:46:33Z")

</div>

Yes, it works. Thank you so much for the time and explanation.

---

<div class="post-metadata">

**Author:** ![jmmease](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmmease/32/3706_2.png) [@jmmease](https://community.plotly.com/u/jmmease)\
**Post date:** [February 19, 2019, 3:05pm UTC](https://community.plotly.com/t/plotly-orca-connectionrefusederror/19723/9 "2019-02-19T15:05:07Z")

</div>

Looks like there was already an issue on this at [https://github.com/plotly/orca/issues/140](https://github.com/plotly/orca/issues/140).  
-Jon

---

<div class="post-metadata">

**Author:** ![claudia](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@claudia](https://community.plotly.com/u/claudia)\
**Post date:** [February 19, 2019, 4:51pm UTC](https://community.plotly.com/t/plotly-orca-connectionrefusederror/19723/10 "2019-02-19T16:51:08Z")

</div>

Yes, in the end I had to touch the ‘/opt/conda/pkgs/plotly-orca-1.2.1-1/lib/orca\_app/resources/app/src/util/create-index.js’ so that every time a new user used it, the /tmp/orca-build/ folder is cleaned and the permissions are set to 777. I modified and added:

```auto
try {
  fs.mkdirSync(PATH_TO_BUILD)
  fs.chmodSync(PATH_TO_BUILD, 0777)
} catch (e) {}
try{
  fs.readdir(PATH_TO_BUILD, (err, files) => {
  if (err) throw err

  for (const file of files) {
    fs.unlink(path.join(PATH_TO_BUILD, file), err => {
      if (err) throw err
    })
  }
})
} catch (e) {}

```

---

<div class="post-metadata">

**Author:** ![jmmease](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmmease/32/3706_2.png) [@jmmease](https://community.plotly.com/u/jmmease)\
**Post date:** [February 20, 2019, 11:18am UTC](https://community.plotly.com/t/plotly-orca-connectionrefusederror/19723/11 "2019-02-20T11:18:11Z")

</div>

Thanks for sharing your solution @claudia!

Changing the permission to 777 after creating `/tmp/orca-build` makes sense to me, but did you need to manually delete any existing files in the directory? I would have thought that the permission change would have been enough, and I’m wondering if deleting the existing tmp files would cause a problem if multiple users are using orca at the same time on the system.

-Jon

---

<div class="post-metadata">

**Author:** ![claudia](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@claudia](https://community.plotly.com/u/claudia)\
**Post date:** [February 20, 2019, 11:57am UTC](https://community.plotly.com/t/plotly-orca-connectionrefusederror/19723/12 "2019-02-20T11:57:28Z")

</div>

The directory is created but begins to fill with other users to use it, in my case, what I do is that every time you create one is erasing the contents of that folder, but for later there may be problem of space.

---

<div class="post-metadata">

**Author:** ![argoneus](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@argoneus](https://community.plotly.com/u/argoneus)\
**Post date:** [April 5, 2019, 4:12pm UTC](https://community.plotly.com/t/plotly-orca-connectionrefusederror/19723/13 "2019-04-05T16:12:58Z")

</div>

I’m seeing this error as well, but it doesn’t appear to be the permissions issue. When I run

```
! /opt/conda/bin/orca serve -p 36785 --plotly /opt/conda/lib/python3.6/site-packages/plotly/package_data/plotly.min.js --graph-only --mathjax https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js --debug

```

The output is:

Spinning up server with pid: 496  
created index-43f6046b-2e91-4648-9979-0244fe75b594.html for plotly-graph component  
{“severity”:“ERROR”,“textPayload”:“gpu process crashed - false”}  
{“severity”:“ERROR”,“textPayload”:“gpu process crashed - false”}  
{“severity”:“ERROR”,“textPayload”:“gpu process crashed - false”}  
{“severity”:“ERROR”,“textPayload”:“gpu process crashed - false”}  
{“severity”:“ERROR”,“textPayload”:“gpu process crashed - false”}  
{“severity”:“ERROR”,“textPayload”:“gpu process crashed - false”}  
Listening on port 36785 after a 7151.992313 ms bootup  
Open routes: /

I’m running orca in a Jupyter notebook via a Docker container managed by Jupyterhub. The container is based on miniconda. Let me know what other details are needed. Thanks!

---

<div class="post-metadata">

**Author:** ![argoneus](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@argoneus](https://community.plotly.com/u/argoneus)\
**Post date:** [April 5, 2019, 4:41pm UTC](https://community.plotly.com/t/plotly-orca-connectionrefusederror/19723/14 "2019-04-05T16:41:49Z")

</div>

If I run the following, the PDF is produced without issues.

(base) root@565ed901eaf0:~# orca graph test.json --format pdf -o test.pdf --verbose  
gpu process crashed - false  
Chrome version 59.0.3071.115  
Electron version 1.8.4  
gpu process crashed - false  
Chrome version 59.0.3071.115  
Electron version 1.8.4  
gpu process crashed - false  
Chrome version 59.0.3071.115  
Electron version 1.8.4  
gpu process crashed - false  
Chrome version 59.0.3071.115  
Electron version 1.8.4  
gpu process crashed - false  
Chrome version 59.0.3071.115  
Electron version 1.8.4  
gpu process crashed - false  
Chrome version 59.0.3071.115  
Electron version 1.8.4  
exported test, in 635.462876 ms

done with code 0 in 636.50 ms - all task(s) completed

---

<div class="post-metadata">

**Author:** ![argoneus](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@argoneus](https://community.plotly.com/u/argoneus)\
**Post date:** [April 5, 2019, 7:41pm UTC](https://community.plotly.com/t/plotly-orca-connectionrefusederror/19723/15 "2019-04-05T19:41:51Z")

</div>

I fixed this issue by adding the -a parameter to the xvfb-run command in my Dockerfile and rebuilding the docker image:

`RUN echo "#!/bin/bash\nxvfb-run -a /opt/conda/lib/orca_app/orca \"\$@\" " > /opt/conda/bin/orca && \ chmod +x /opt/conda/bin/orca`

---

<div class="post-metadata">

**Author:** ![jmmease](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmmease/32/3706_2.png) [@jmmease](https://community.plotly.com/u/jmmease)\
**Post date:** [April 8, 2019, 11:15am UTC](https://community.plotly.com/t/plotly-orca-connectionrefusederror/19723/16 "2019-04-08T11:15:33Z")

</div>

Hi @argoneus, thanks for sharing your solution!  
-Jon
