runpod-python icon indicating copy to clipboard operation
runpod-python copied to clipboard

Restart API not working

Open sumitflickstree opened this issue 5 months ago • 7 comments

Bug: Runpod restart API not working

Endpoint: POST https://rest.runpod.io/v1/pods/{pod-id}/restart

Description: When calling the restart API, it returns a success response (200 OK) but the pod does not actually restart. There is no change in pod state or behavior.

Steps to Reproduce:

Send a POST request to the above endpoint with a valid pod ID and API key

Observe the response

Check pod status — it remains unchanged

Expected Result: The pod should stop and start again, similar to a manual restart from the dashboard.

Actual Result: API returns success, but pod continues running without restarting.

Notes:

Tried with multiple pods and tools (curl, Postman)

Manual restart from dashboard works fine

sumitflickstree avatar Jul 28 '25 11:07 sumitflickstree

I think there's not restart option right now. If you needed restart the pod you can first call the runpod.stop_pod(pod_id) then wait for the pod to stop e.g time.sleep(wait_time) then use resume_result = runpod.resume_pod(pod_id, gpu_count)

kowshik24 avatar Jul 30 '25 13:07 kowshik24

@deanq if needed the /restart api can I work on that?

kowshik24 avatar Jul 30 '25 13:07 kowshik24

Stopping the pod resets the data, which I don't want. Restarting it doesn't delete the data.

sumitflickstree avatar Jul 31 '25 05:07 sumitflickstree

I've filed a bug with the team, thanks for this report. It does seem that there are deeper issues after my investigation and I've passed it along in a ticket.

justinwlin avatar Aug 04 '25 23:08 justinwlin

As an unofficial work around, what I've done is I wrote a script you can run in your chrome console:

When you click the restart button will show you an api request you can make that the restart button is making. I've checked it works.

Not officially supported, but depending on your use case this could be a temporary hold over.

// Network Request Interceptor for Pod Restart
(() => {
  console.log('🚀 Pod Restart Network Interceptor Active');
  
  // Store original fetch
  const originalFetch = window.fetch;
  
  // Override fetch to log requests
  window.fetch = async function(...args) {
    const [url, options = {}] = args;
    
    // Check if this is a restart request
    if (url.includes('/restart')) {
      console.group('🔄 POD RESTART REQUEST DETECTED');
      console.log('📍 URL:', url);
      console.log('🔧 Method:', options.method || 'GET');
      console.log('📋 Headers:', options.headers || 'No headers');
      console.log('📦 Body:', options.body || 'No body');
      
      // Log all headers if they exist
      if (options.headers) {
        console.log('📑 Header Details:');
        if (options.headers instanceof Headers) {
          for (let [key, value] of options.headers.entries()) {
            console.log(`  ${key}: ${value}`);
          }
        } else {
          console.log(options.headers);
        }
      }
      
      // Create curl command
      let curlCommand = `curl --request ${options.method || 'GET'} \\\n  --url "${url}"`;
      
      if (options.headers) {
        if (options.headers instanceof Headers) {
          for (let [key, value] of options.headers.entries()) {
            curlCommand += ` \\\n  --header "${key}: ${value}"`;
          }
        } else {
          for (let [key, value] of Object.entries(options.headers)) {
            curlCommand += ` \\\n  --header "${key}: ${value}"`;
          }
        }
      }
      
      if (options.body) {
        curlCommand += ` \\\n  --data '${options.body}'`;
      }
      
      console.log('📝 CURL Command to reproduce:');
      console.log(curlCommand);
      console.groupEnd();
    }
    
    // Call original fetch
    try {
      const response = await originalFetch.apply(this, args);
      
      // Log response for restart requests
      if (url.includes('/restart')) {
        console.group('✅ POD RESTART RESPONSE');
        console.log('📊 Status:', response.status, response.statusText);
        console.log('📑 Response Headers:');
        for (let [key, value] of response.headers.entries()) {
          console.log(`  ${key}: ${value}`);
        }
        
        // Clone response to read body without consuming it
        const clonedResponse = response.clone();
        try {
          const responseData = await clonedResponse.text();
          console.log('📄 Response Body:', responseData);
        } catch (e) {
          console.log('📄 Could not read response body');
        }
        console.groupEnd();
      }
      
      return response;
    } catch (error) {
      if (url.includes('/restart')) {
        console.error('❌ POD RESTART ERROR:', error);
      }
      throw error;
    }
  };
  
  // Also intercept XMLHttpRequest if needed
  const originalXHR = window.XMLHttpRequest;
  window.XMLHttpRequest = function() {
    const xhr = new originalXHR();
    const originalOpen = xhr.open;
    const originalSend = xhr.send;
    
    xhr.open = function(method, url, ...args) {
      xhr._url = url;
      xhr._method = method;
      return originalOpen.apply(this, [method, url, ...args]);
    };
    
    xhr.send = function(body) {
      if (xhr._url && xhr._url.includes('/restart')) {
        console.group('🔄 POD RESTART XHR REQUEST');
        console.log('📍 URL:', xhr._url);
        console.log('🔧 Method:', xhr._method);
        console.log('📦 Body:', body);
        
        // Log request headers
        console.log('📑 Request Headers:', xhr.getAllResponseHeaders());
        console.groupEnd();
      }
      
      return originalSend.apply(this, arguments);
    };
    
    return xhr;
  };
  
  console.log('✅ Interceptor ready! Click the restart button to see the network details.');
})();

justinwlin avatar Aug 04 '25 23:08 justinwlin

I've filed a bug with the team, thanks for this report. It does seem that there are deeper issues after my investigation and I've passed it along in a ticket.

HI @justinwlin any updates on this?

sumitflickstree avatar Aug 07 '25 07:08 sumitflickstree

Hello!

Any update on this? It still does not work

talhadar90 avatar Oct 13 '25 09:10 talhadar90