Incoming connections
Many tools, such as Tensorboard and Streamlit, require a local webserver to be spun up to serve docs, dashboards, and other web interfaces. They often prompt you to open an address like http://localhost:8080)
.
When you enable incoming connections, Deepnote exposes port 8080
on the internet under an address such as b9d13315-f12a-4931-857c-ed6b4c59dcad.deepnoteproject.com
. You can use this address to access services running on port 8080
on your Deepnote machine.
How to allow Incoming connections
You can allow incoming connections from the Project tab in the right sidebar. From there, click on the arrow next to Environment to be taken to the and then toggle "Allow incoming connections" at the bottom.
If you want to try it out, paste !python -m http.server 8080
into a block and run it. If incoming connections have been enabled as described above, you should be able to paste the provided link into a browser to connect to the running webserver.
What if I need to expose a different port?
Right now we only support exposing port 8080. To expose other ports, you can either reconfigure your tool, or use utilities like socat
which can forward traffic from port 8080
to the port of your choosing. You can use the example below to set up port forwarding with socat
in the terminal:
apt update && apt install socat
socat tcp-l:8080,fork,reuseaddr tcp:127.0.0.1:YOUR_PORT
Running Flask
You can also use Deepnote to prototype a simple Flask server. When using its development server, don't forget to set the host
to reach it from outside the local machine.
Example:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello_world():
return "<p>Hello, World!</p>"
app.run(host='0.0.0.0', port=8080)