Sandbox URL

Each sandbox has its own URL that you can use to connect to any service running inside the sandbox.

For example, you can start a server inside the sandbox and connect to it from your browser.

import { Sandbox } from 'e2b'

const sandbox = await Sandbox.create({ template: 'base' })

const url = sandbox.getHostname() 
console.log('https://' + url)

await sandbox.close()

If you want to get an URL for a specific port inside the sandbox, pass the port number to the getHostname()/get_hostname() method.

import { Sandbox } from 'e2b'

const sandbox = await Sandbox.create({ template: 'base' })

const openPort = 3000
const url = sandbox.getHostname(openPort) 
console.log('https://' + url)

await sandbox.close()