proxy requests through Machines private_ip

I am facing a problem here trying to proxy all requests through a new machine private_ip but i get ENOTFOUND on the ip:

app.use(async (req, res, next) => {
	try {
		const { ip, id } = await newMachine();

		const proxyMiddleware = createProxyMiddleware({
			target: `http://${ip}:80`,
			changeOrigin: true,
			onError: async (err, req, res) => {
				console.error("An error occurred while proxying the request:", err);
				await killMachine(id);
					message: "An error occurred while proxying the request.",
					error: err,
			onProxyRes: async (proxyRes, req, res) => {
				await killMachine(id);
				console.log(`Request to ${req.url} was successfully proxied.`);

		proxyMiddleware(req, res, next);
	} catch (error) {
		console.error("Error creating a new machine:", error.message);
		res.status(500).json({ message: "Error creating a new machine.", error });

Assuming the ip address is ipv6, you need square brackets in the URL:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.