A battle takes place on the outskirts of a colonized solar system between attacking and defending forces. Would any stray shots have a chance of hitting a ship or station closer to the center of the system?
Millions of shots are fired, most from railguns or similar weapons. Lasers are used mostly on larger ships, as smaller ships can't handle the heat they output. Nuclear missiles are used, but usually hit their target.
There are a few inhabited planets in the solar system, and there is frequent trade and transport between them, large space station factories, and other nearby systems. The entire solar system resembles the Sol system in size.
Is there any chance of railgun rounds or even lasers traveling far enough to be a danger to the stations or ships in the system? What would the effective range of these weapons be?
Lasers? No. Lasers need to be focused. They diffuse fairly quickly (on solar distance scales) and the more they diffuse the less damage they cause. I don't believe they'd be dangerous to anything not inside the battle.
Railgun rounds? There's a chance, but it's infintesimlally (read: "only if you say so in your story") low. They'll just burn up in planetary atmospheres, so it's really only ships and bases that are at risk. Unfathomably low risk. Not zero, but relly low (as in "millions of rounds wouldn't bring the percentage chance to 0.1% low").
Nuclear missles (I know you said they almost always hit, but just for completeness). Honestly, the chance of this much-larger-than-a-railgun-round object hitting something are only slightly better than the railgun round itself. But, if they're armed when they go missing... then there's a chance they'd go off in planetary atmosphere. It would still be written in as inevitable in your story ("Make it happen, Number One!"), but what a light show!
In the long run, I'd say you need to throw out the statistics and use or not use the idea to serve a purpose in your story. When you do, a totally rational comment like, "what were the odds of that!" would be appropriate.
Wow! This is something I have honestly never thought about! But now I will :P
Every object within a solar system has only a few possibilities where it might fly along:
Now, how high are the risks for a stray bullet hitting anything in that star system. To be honest, I think that the chance of being hit by a lightning, a comet and a freight train simultaneously would be higher. Remember,
Space is big. Really big. You just won't believe how vastly, hugely, mind-bogglingly big it is. I mean, you may think it's a long way down the road to the chemist, but that's just peanuts to space. (The Hitchhiker's Guide to the Galaxy, Douglas Adams)
The chance that some of these stray bullets hit something are, honestly, astronomically small (Pun intended).
But how about lasers and other beam weapons? Most lasers do not keep their focusing for a long time. I remember an experiment where my physics teacher took a laser from the lab, pointed it across the yard and showed us that the beam diameter increased significantly. Your weaponized laser may be more precise, but even they would loose energy on interplanetary distances. Maybe they would heat up a distant space ship or station, but nothing more.
Tl;dr: Only in a vein of very very very very VERY bad luck would something being hit and receive damage.
Don't think it would cause any problems to people on the planets, as meteors much larger than bullets(even cannonballs) have simply burn'd up in the atmosphere. Space is big, but it could happen(not sure how likely) that some of the bullets hit other ships nearby, depending on how many were fired. As far as lasers are concerned, it would depend on how well focused they are(see this what if xkcd article for more information about that). If a missile missed all the ships, but was programmed to seek something, then either some other ships or some place on one of the planets would have a bad problem if it didn't hit the star or get really confused and run out of the system. Anything that doesn't seek out anything isn't really likely to do anything but get sucked into a planet or the star or just fly off into deep space.
Compare with objects in Earth orbit.
Look at a real-time display of stuff in orbit. This represents over 21,000 objects in Earth orbit. This is very, very restricted compared to the size of the solar system. The volume of the solar system compared to earth orbit is on the order of 1E15 times as large.
Given how crowded Earth orbit is, and that the foreign object density is trillions times greater, clearly the collision rate in Earth orbit must be huge in comparison -- yet actual impacts with space debris in earth orbit are rare. They do occur, proving that impacts are possible and will occur given time and chance -- the frequency of impacts is decidely low. It will be many many times smaller for bullets fired from the edge of the solar system.
The number and energy of the objects is lost in the background noise.
ISS already gets hit by stuff; it has armor and emergency procedures in place. With bigger stations and budgets redundant systems should be able to absorb occasional high energy impacts with minimal disruption.
There are about half a million tracked objects near Earth between 1 and 10cm: Holding your space battle in orbit would only about triple the chance of something getting hit by accident.