Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

319
Views
OBTENER http://127.0.0.1:8000/net::ERR_CONNECTION_REFUSED error al obtener datos del servicio de back-end en el mismo servidor web

Tengo una aplicación muy simple que se ejecuta en un servidor web. Un poco de Javascript solicita algunos datos de un servicio FastAPI. Cuando visito el dominio, aparece el siguiente error en la consola GET http://0.0.0.0:8000/ net::ERR_CONNECTION_REFUSED .

Si entro en el servidor web, puedo curl localhost:8000/ y obtener los datos.

Entonces, la página web existe y el servicio de backend se está ejecutando. Pero el frontend no llega al backend. ¿Alguien podría explicar qué estoy haciendo mal aquí?

 <html> <head></head> <body> <h1>RSS Reader</h1> <ul id="feeds_list"></ul> </body> <script> const ul = document.getElementById("feeds_list"); const data = fetch("http://127.0.0.1:8000/", { method: "GET", headers: { "Content-Type": "application/json", "Access-Control-Allow-Origin": "*", }, mode: "cors", }) .then((data) => { return data.json(); }) .then((res) => { res.forEach((element) => { const li = document.createElement("li"); const a = document.createElement("a"); a.appendChild(document.createTextNode(element.title)); a.href = element.link; a.setAttribute("target", "_blank"); li.appendChild(a); ul.appendChild(li); }); }); </script> </html>
 import json from pathlib import Path import pandas as pd from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware PARENT_DIR = Path(__file__).parent.parent.resolve() app = FastAPI() app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"] ) @app.get("/ping") def ping(): return {"ping": "pong"} @app.get("/") def root(): df = pd.read_csv(f"{PARENT_DIR}/data/latest.csv") df.to_json(f"{PARENT_DIR}/data/latest.json", orient="records") with open(f"{PARENT_DIR}/data/latest.json") as f: data = json.load(f) return data if __name__ == "__main__": app()
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!