Running a script in a Jupyter Notebook cell fails and returns an error in the command prompt

Last Published: April 25, 2020


Attempts to run a script in a Jupyter Notebook cell fail with no error returned in the notebook. However, the following error is returned in the command prompt.

zmq message arrived on closed channel
The image of the zmq error


By default, Jupyter Notebook uses port 8888. However, the port may be inaccessible due to the machine’s firewall security or if it is used by another application. The port numbers' availability can be checked using Windows Command Prompt. To do so, run the following command:

netstat -na | find "<port number>"

The following image is a sample result of the command.

The image of the netstat command

Solution or Workaround

To resolve this issue, start Jupyter Notebook with a custom port number. Check the availability of the desired port, and run the following command in the Python Command Prompt:

jupyter notebook --port=<port number>
User-added image

Alternatively, the default start port can also be changed. To do so:

  1. Start the Python Command Prompt and run the following command. This command creates a .py file, jupyter_notebook_config.
jupyter notebook --generate-config
  1. Navigate to the following folder location:
  1. Edit the file using a text editor, for example, Notepad++ or IDLE.
  2. Find and uncomment the script, c.NotebookApp.port = 8888.
  3. Edit the port number to the desired port number, for example:
c.NotebookApp.port = 8889
Image sample of the file

Article ID:000015077

  • ArcGIS API for Python 1 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic